Export the function from your executable by using the export/exports
directives. Import it dynamically in your DLL by using the HInstance
from the application.

Sample:

program EXE;
{$APPTYPE CONSOLE}
uses Windows;
procedure Callback; export;
begin
  WriteLn('Callback called');
end;
exports Callback;
var DLLHandle: THandle;
begin
  DLLHandle := LoadLibrary('DLL.dll');
  ReadLn;
  CloseHandle(DLLHandle);
end.

library DLL;
uses Windows;
type TCallback = procedure;
var Callback: TCallback;
begin
  Callback := GetProcAddress(MainInstance, 'Callback');
  Callback;
end.

\/\//\.


On 4 Dec 2007 08:23:27 -0000, Vivek <[EMAIL PROTECTED]> wrote:
>
>  I have to use a function in DLL which is declared in exe .
>  Function should be method of any class of the exe.
>
>  I tried a lot but could not succeed.
>
>  Regards,
>  Vivek

Reply via email to