I have been trying to load a 32-bit dll using C++ (from a 32-bit application, on windows 7 64-bit). LoadLibrary returns NULL, and GetLastError returns 126 for "The specified module could not be found."
I am passing in the complete address to the LoadLibrary function. I opened the dll in Dependency Walker, which said GPSVC.dll was a missing dependency.
From the googling I've done, it looks like Dependency Walker often falsely shows this GPSVC.dll as a missing dependency, and there is no 32-bit version of the it, so I don't think that that's the actual problem.
I haven't done too 开发者_如何学编程much finagling with dlls in the past, so hopefully it's a relatively simple problem that I can learn from.
Thanks in advance for any help!
Well I solved my problem, and unfortunately it's a fairly obvious solution. I added the directory that contained my dll to the PATH variable. Apparently dlls don't look in their own directory for their dependencies.
Can you debug into the DllMain of the other dll? If yes you could check directly in the debugger. With Windbg you can break on module load so you can single step what happens. Do you link directly against the lib of the dll? If not you could try to do so to check what error message the OS will show you. If it is 0xC0000142 then DllMain did return false. If it is 0xC0000022 then the executable or one of the dependant dlls do not have execute rights. You code 126 is simply Module not found which seems to tell the whole story. You could set the PATH variable to the directory by hand to the location of the missing dll. Do you deploy the dll to some other machine? If yes it could be that you are linking against the debug C-Runtime which is not installed on normal machines.
Yours, Alois Kraus
精彩评论