Board index » delphi » passing a function parameter to a C dll

passing a function parameter to a C dll

Anybody have any ideas on how to pass a function as a parameter to
another function within a C dll? Here's the C call:

int     mydllfunc(char FAR *fname,
        int (FAR PASCAL *handler)
        char FAR *filename));

Here's how it works. You pass a filename (fname) to the dll function. Each
time it searches and returns a non-null, it returns true and invokes the
handler, which, in turn is passed the the same *filename for further
processing.When the search for fname returns a null the function is
exited.

This didn't work (and forgive any syntax errors this is from memory)

{compiler set to force far calls}
Type
        ahandler = function(myfilename : pchar) : integer;      

var    
        myhandler : ahandler;  

function mydllfunc(fname : pchar; myhandler : ahandler) : integer;
        external 'mydll';      
Any help/code examples would be appreciated.    

 

Re:passing a function parameter to a C dll


Quote
co...@ftp.com (Colin Mahon) wrote:
>Anybody have any ideas on how to pass a function as a parameter to
>another function within a C dll? Here's the C call:
>int         mydllfunc(char FAR *fname,
>    int (FAR PASCAL *handler)
>    char FAR *filename));
>{compiler set to force far calls}
>Type
>    ahandler = function(myfilename : pchar) : integer;      
>var
>    myhandler : ahandler;  
>function mydllfunc(fname : pchar; myhandler : ahandler) : integer;
>    external 'mydll';      
>Any help/code examples would be appreciated.        

you need to write a function for and set ' ahandler' to its address.
--
Chuck Eckenroed
Sun Valley Software, Inc.

Other Threads