Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem while using "LoadLibrary(...)" 1

Status
Not open for further replies.

firelex

Programmer
Jan 10, 2002
118
0
0
DE
Hello, all!
The situation is:
I have a dll. Now I want to attach it to a process. But
Code:
     LoadLibrary("MyDll.dll")
Always returns
Code:
NULL
!
First I thought the path is wrong, but
Code:
  WIN32_FIND_DATA FileData;
  HANDLE hFile;	
  hFile = FindFirstFile(path, &FileData);
  if (hFile != INVALID_HANDLE_VALUE) {
	TRACE (&quot;\nFile <%s> exists!!!\n&quot;,path);
  } else {
	TRACE (&quot;\nFile <%s> doesn't exist\n&quot;,path);
  }

Always says that file exists!

Any ideas?
 
use GetLastError/FormatError to see what is up.

Ion Filipski
1c.bmp
 
Code:
GetLastError
says the error is 126 -> specified module cannot be found!
 
In this case
1. specify full path to your dll:
LoadLibrary(&quot;disk:\\directories\\MyDll.dll&quot;)
or
2. put your dll in some system directlry
or
3. Add to environment variable Path the directory where is situated your dll.

Ion Filipski
1c.bmp
 
I've tried the full path and PATH-variable also - no luck.
It is like WooDoo: by my dll
Code:
LoadLibrary
always returns error #126, but as I tried another dll from windows\system32 it worked...
What does it mean
Code:
ERROR_MOD_NOT_FOUND
, if it is given back by
Code:
LoadLibrary
? Is it like &quot;file not found&quot; or something else?
 
Look in MSDN what does ERROR_MOD_NOT_FOUND mean.

Ion Filipski
1c.bmp
 
Hi,

it just could be that your DLL is dependant of some other module which is actually not found by the system. You might want to check that (using Dependency Walker)

Hope this helps,
Tobi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top