Saurabh Rai wrote:
>> ----- Original Message ----- 
>> From: Rob Kennedy 
>> To: [email protected] 
>> Sent: Thursday, November 29, 2007 12:07
>> Subject: Re: [delphi-en] Delphi Urgent !
>> 
>> 
>> Saurabh Rai wrote:
>>> Have a function created in the exe which has to be used in the DLL
>>> 
>>> Is it possible???
>> 
>> Yes. Have the EXE call a function in the DLL. Among the parameters, 
>> include a pointer to the EXE's function. The DLL can keep that pointer 
>> and call the function when it wants.
> 
> please , i need a example .
> suppose 
> 
> EXE ---------------------
> Function TExclass.Function : Integer ;
> Begin 
> //
> End;
> 
> DLL----------------

In the EXE:

type
   TFoo = function(bar: Integer; baz: Double): Boolean;

function Foo(b: Integer; z: Double): Boolean;
begin
   Result := b * z = 0;
end;

function Quux(fn: TFoo): Pointer; external 'dll.dll';

if nil <> Quux(Foo) then ;

In the DLL:

type
   TFoo = function(bar: Integer; baz: Double): Boolean;

function Quux(fn: TFoo): Pointer;
begin
   if fn(4, 5.2) then
     Result := nil
   else
     Result := @Result;
end;

exports
   Quux;

-- 
Rob

Reply via email to