Hi,

You will have to declare the function identically in the both the main app and dll. Then pass a pointer containing the address of the function in the main app when calling procB. Alternatively declare an extra export in the dll allowing to register this main app function.

(delphi syntax)

main app:
procedure procA(); cdecl; begin (* *) end;
procedure procB(); cdecl; external 'mydll';

procB (a, b, @procA);

dll:
type TprocA=function(); cdecl;
function procB (a,b: Integer; procA: TprocA); cdecl;
begin
 procA();
end;

sorry for the delphi syntax but c(++) should be simular..

regards,

rene


[EMAIL PROTECTED] schreef:
I'm trying to add the ability to dynamically load DLLs
containing SQL functions and collating sequences to
SQLite.  Things are working great on Unix, but I'm having
issues with Windows.  Windows experts, please help me.

Suppose the main program (the .exe file) contains a
function procA() and the DLL contains a function procB().
I want procB() to be able to call procA().  The idea
is that the main program uses LoadLibrary() to pull
in the DLL, then GetProcAddress() to find the address
of procB().  Then the main program calls procB() in
the DLL which in turn calls procA() in the main program.

This all works great on Unix.  When I use dlopen() to
attach the shared library, the procA() reference in the shared library is automatically resolved to the
address of procA() in the main program.

But on Windows, I cannot get the DLL to compile because
it is complaining about the missing procA().

Another way to ask the question is this:  How do I build
a DLL in windows that can call routines contained in the
main program that attached the DLL using LoadLibrary()?

--
D. Richard Hipp   <[EMAIL PROTECTED]>



Reply via email to