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


|