Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Delphi > Re: Setting Up ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 2 Topic 1071 of 1134
Post > Topic >>

Re: Setting Up Callback

by Jamie <jamie_ka1lpa_not_valid_after_ka1lpa_@[EMAIL PROTECTED] > Jul 15, 2006 at 09:32 PM

Phil Grace wrote:
> Hi,
> 
> I'm trying to set up a callback from a function in a .dll and can't
> seem to land on the right syntax....
> 
> The function itself is defined like this :
> 
> { typedefs with special meaning }
> aDHandle = integer;	{ database file handle }
> aLong = Longint;	{ 32-bit signed integer }
> aResult = integer;	{ returned result code }
> 
> function  PclReindex (fdh:aDHandle; kmask:aLong;
> callback:integer):aResult; stdcall;
> 
> ... and then I need to define a function like this :
> 
>    aReindexCallback = function (funcno:anInt; par1:aLong;
> par2:aLong):aResult;
> 
> ... what I have ben playing around with is the following, the compiler
> complains with "Not enough actual parameters".
> 
> function ReindexCallback (funcno:anInt; par1:aLong;
> par2:aLong):aResult; 
> begin
>   result := 0;
> end;
> 
> procedure TMainForm.Reindex (sPath, sFile : string ); var
>   sFilename : string;
>   fh : integer;
>   cb : aReindexCallback;
> begin
>   sFilename := (sPath + '\' + sFile);
>   fh := OpenAFile ( sFilename );
>   Progress ( format('Reindexing %s ...',[sFilename]) );
> 
>   cb := ReindexCallback;
>   PclReindex( fh, 0, cb);
>   PclClose(fh);
> end;
> 
> 
> 
> any help would be much appreciated.
> 
> Regards,
> Phil.
> 
  not sure what your trying here but is an an example
of an API in the system that is a call back..

  --- in your app code ----

  Function EnumWIndowsProc(handle:Thandle, UserData:Dword):Booland;
stdcall
   Begin
     if // what ever Result := true else
    result := false;
   End;

--- some where in your initiation of this. ---
   EnumWindows(@[EMAIL PROTECTED]
);

--------------
   the EnumWindows is a function in one of the
systems DLL's that sets up a vector address to
your EnumWindowsProc..
   by using the "@[EMAIL PROTECTED]
" you can pass the address of
this function ot the procedure call in the DLL.
  you have to create a function/procedure in the
DLL to accept the address and set up the vector
ect....

  - for example in the DLL ----
Var
  DLLEnumWindowsProcVector:function(Handle:Thandle, 
UserData)Boolean;Stdcall;

---- now the call your app would make to the DLL ----
  procedure SetUpMyCallBackVector(P:Pointer);
   Begin
     DLLEnumWIndowsProcVector := P;
   End;

---- now some where in your DLL code  ----
   DLLEnumWindowsProcVector(SomeHandle, SomeUserData);

   this will actually call the function in your APP..
  all you need to do is ex****t the SetUpMyCallBackVector procedure
so that you can link it in the main APP>.
for example..

  procedure SetCallBack(P:Pointer) external 'DLLNAME.DLL' name 
'SetUpMyCallBackVector';

  and to use it in the app
  SetCallBack(@[EMAIL PROTECTED]
);
ect...
  etc ... and the list goes on...


-- 
Real Programmers Do things like this.
http://webpages.charter.net/jamie_5
 




 2 Posts in Topic:
Setting Up Callback
Phil Grace <phil@[EMAI  2006-07-10 03:30:01 
Re: Setting Up Callback
Jamie <jamie_ka1lpa_no  2006-07-15 21:32:15 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Aug 28 1:10:53 CDT 2008.