jeez this is really driving me nuts
Not two DLL tutorials on the net say the same thing, wtf? I need for my work to build a DLL in MSVC that exports a function and an executable in MSVC too that will call this function in the DLL.
I have made a simple DLL that has 2 functions and looks like this:
Code:
int WINAPI DllMain (HINSTANCE hinstDLL, unsigned long fdwReason, void *lpvReserved)
{
return (TRUE);
}
void InputPluginAPI (char *input_pathname, block_t *output_blocks)
{
// this function reads and translate the data from a CSV file into block structures.
// [snip] code follows...
}
I have made a .def file for this DLL
Code:
LIBRARY in_cms
EXPORTS
InputPluginAPI
SECTIONS
.data READ WRITE
It builds okay. Normally the in_cms.dll should be exporting the InputPluginAPI function, right ?
Now when I try to load it and call it in my main project executable... (here's the WinMain function of this executable)
Code:
typedef void (*IN_PLUGINAPI) (char *input_pathname, block_t *output_blocks);
IN_PLUGINAPI ImportedFunction;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, char *lpCmdLine, int nCmdShow)
{
// program entrypoint
// load the input DLL
hInputDll = LoadLibrary ("in_cms.dll" );
if (hInputDll == NULL)
TerminateOnError ("WinMain(): unable to load input DLL\n"); // bomb out on error
// get a pointer to the input plugin API
ImportedFunction = (IN_PLUGINAPI) GetProcAddress (hInputDll, "InputPluginAPI");
if (!ImportedFunction)
TerminateOnError ("WinMain(): unable to get input plugin API\n"); // bomb out on error
// rest of function follows...
}
it fails to GetProcAddress() for the function I want to call in my DLL!
What am I doing wrong ??? :'(