mode one adopts LoadLibraryEx
Reprint: http://blog.sina.com.cn/s/blog_62ad1b8101017qub.html
If the DLL is not in the same directory as the caller, it can be loaded with LoadLibrary (L "DLL absolute path"). However, if another DLL is called inside the calling DLL, the call will still fail. The solution is to use LoadLibraryEx:
LoadLibraryEx ("DLL absolute path", NULL, Load_with_altered_search_path);
By specifying Load_with_altered_search_path, let the system DLL search order begin with the directory where the DLL is located.
mode two adopts Setcurrentdir
Reprint: http://blog.csdn.net/flyayi2006/article/details/5526982
Calling DLLs across directories, you should do this
1 saving the current working directory with Getcurrentdir
2 using Setcurrentdir to set the current working directory to the path where your DLL is located, you need to use the absolute path
3 using LoadLibrary your DLL
4 using Setcurrentdir to revert to the original working path
Example
TCHAR Chcurdir[max_path] = {0};
GetCurrentDirectory (MAX_PATH, chcurdir);
SetCurrentDirectory (_t ("e:\\test\\"));
M_hdll = LoadLibrary (_t ("MyTest.dll"));
SetCurrentDirectory (Chcurdir);