Click to See Complete Forum and Search --> : Loading DLL :Module not found.


April 20th, 1999, 08:05 AM
Hi,
I've being trying to load a DLL in VC++ 5 using LoadLibrary.
I'm specifing the path correctly and the DLL exists but I get a Module not Found Error when the code executes.
The code loading the DLL is part of another DLL which is accessed through JNI from a java program.
Any Ideas why LoadLibrary can't find the DLL. I've used LoadLibrary sucessfully previously in other projects and the code is similar.
Thanks,

Paul McKenzie
April 20th, 1999, 10:37 AM
The first thing that I would do is write a very small Windows program that attempts to load a library by calling LoadLibrary() and report whether the library loads or not. The program does nothing else (except call FreeLibrary() at the end). You don't need wizards or MFC to do this: (Note, the code has not been tested, but gives you the basic idea of what I'm talking about)

#include <windows.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCommandLine, int nCmdShow)
{
HINSTANCE hLibModule=LoadLibrary("WHATEVER");
char szBuf[100];
if ( !hLibModule )
wsprintf(szBuf, "Error Loading DLL %s: Code = %d", "WHATEVER", GetLastError());
else {
wsprintf(szBuf, "%s Loaded successfully", "WHATEVER");
FreeLibrary(hLibModule);
}
MessageBox(NULL,szBuf,"DLL Status",MB_OK);
}


If it fails, the problem is more basic than anything to do with Java or JNI. If the program is successful, revisit your code to see what the potential problem may be.

Regards,

Paul McKenzie