Click here to Skip to main content
15,889,874 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,I am a new commer.
I face to surprise problem now:
Using VC6.0 I edit this code to load dll in my computer,It is just OK to return HANDLE,
but when I copy the code to another Win7 PC to compile and run,hdllHandle always return NULL。
I have debug and Check that Relative path we point is OK.
What is the problem? Thanks you in advance.

CString csDllPath=m_strWorkPath+"\\CmdDLL.dll"; //Relative path is OK
HINSTANCE hdllHandle;
hdllHandle=LoadLibrary(csDllPath);
Posted

As per the very documentation[^], on LoadLibrary failure, you should call GetLastError to obtain useful info.
 
Share this answer
 
Comments
Anderson_zhan2 20-Nov-15 22:35pm    
GetLastError is just 126,Can not find module.
But It is OK in my PC.My code is not modified but seems have different result between PCs
I just takes a few hours to fix it.
The root cause is the some dependecy dll lost in the PC environment.
Download the Dependency Walker tool to find out which dlls the PC do not have,than copy these DLL from the PC you can load successfully.
Thanks for your reply, Permalink.
 
Share this answer
 
Comments
Patrice T 21-Nov-15 2:30am    
Please close the question if solved
Anderson_zhan2 26-Nov-15 22:34pm    
Sorry,I am a new commer,how to close it?
Patrice T 27-Nov-15 1:32am    
No problem.
you should have a link saying something like "Closed" or "Solved"
Anderson_zhan2 27-Nov-15 1:59am    
I try to find,but still can not find the link you say.Could you give a photo to indicate?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900