Other Languages - LoadLibrary returns no handle getlasterror() returning value 0

Asked By Mandar on 06-May-11 08:03 AM
Hello,
          In my code i am using loadlibrary to load a dll. But during execution that loadlibrary is returning null handle and when i do getlasterror() it returns 0. So can anyone help me to figure out what the problem is and if possible if any solution available for this? i am not getting why my dll is not getting loaded using loadlibrary().?

thanks and regards,
Maddy
Riley K replied to Mandar on 06-May-11 12:01 PM
The code is rather simple:

HINSTANCE hModule = LoadLibrary(strLibPath);
ASSERT(NULL != hModule);
if (NULL == hModule) {
DWORD dwError = ::GetLastError();
// ...
}

In one specific case, the API failed because strLibPath pointed to a
nonexistent DLL (result of a config error).  So, instead of ".\\bin\\my.dll"
it was set to ".\\my.dll".   The library gets loaded without any problems
otherwise.