Setting Up Callback

Giganews Newsgroups
Subject: Setting Up Callback
Posted by:  Phil Grace (ph…@niche-cs.com)
Date: 10 Jul 2006

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.

Replies