LoadLibraryA返回NULL

Problems: I builded a pure windows dynamic DLL(both lib and dll), when I use LoadLibraryA to load this dll in other application under VS2015 in windows 10 platform. I got this issue.

Solutions:

First, Get the error message using GetLastError(), and I got return value(126), means it can't find the module.

Second. Use the full path to instead the relative path if it has. and use follows function:

hDLL = LoadLibraryEx(str.c_str(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH);

 If the issue gone, that's fine. Or, there is another possible reason. The loaded DLL has lost someone depencies. Here, I suggest one tools to find which one is lost, the download link is:Depends Tools . Open the tool, just drag the dll to the panel.

Then copy all the dependency dll to the export DLL path, and rebuild it. I think it will be OK.

猜你喜欢

转载自blog.csdn.net/jiaken2660/article/details/106919147