> -----Original Message----- > From: Robert Simpson [mailto:[EMAIL PROTECTED] > Sent: Wednesday, June 07, 2006 7:55 AM > To: 'sqlite-users@sqlite.org' > Subject: RE: [sqlite] DLLs containing user-defined SQL functions > > > -----Original Message----- > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > > Sent: Wednesday, June 07, 2006 7:30 AM > > To: Sqlite-users > > Subject: [sqlite] DLLs containing user-defined SQL functions > > > [snip] > > 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()? > > The main executable would have to export the function through > a .DEF file, and your DLL would have to get the pointer to > the function through GetProcAddress() as follows: > > proc = GetProcAddress(GetModuleHandle(NULL), > "exe_exported_func_name");
A caveat: It's uncommon for executables to export functions, but not unheard of. Regular C/C++ programs will have no problem adapting to this mechanism, but other languages that either don't use an exe, or use a proxy exe, could not support it without additional SQLite API's to change the load behavior. You'd need options to either allow you to set a compile-time directive to hardcode the function, or to specify what HMODULE to call GetProcAddress() on.