LoadLibrary failed with a return code of 126 
Author Message
 LoadLibrary failed with a return code of 126

I am trying load a DLL in the \Windows directory using the LoadLibrary
function. I tried different ways to specify the library name with or
without the path. It always returns NULL. The error code returned by
GetLastError() is 126 that means the specified module could not be
found, but the DLL exists in the \Windows directory.

The following are the statements I tried:
HINSTANCE hDLL = LoadLibrary(TEXT("\\Windows\\snmp-mibii.dll"));

HINSTANCE hDLL = LoadLibrary(TEXT("snmp-mibii.dll"));

Could anybody give me some hint what may be wrong? Thanks.

Ruth Hsu
Intermec Technologies Corporation



Tue, 14 Sep 2004 10:12:29 GMT  
 LoadLibrary failed with a return code of 126
It's likely that your DLL depends on another DLL that is not present.  Make
sure all DLLs are present in a place the loader will look (check the SDK
LoadLibrary() help to see the search the loader will do).

To get a list of DLLs your DLL is dependent on, use "dumpbin /imports
snmp-mibii.dll" from your desktop machine.  You will get a listing of all
DLLs that your DLL calls directly.  Note that this is only a first-level
dependency check.  Those DLLs can in turn have other dependencies, of
course.

Other possibilities:
    the file doesn't actually exist (spelling?)
    you don't have UNICODE defined at build time (unlikely - you'd have to
specifically remove it as it is the default setting)
    the file is in use with no sharing (though you'd probably get a
different error code in this case)

HTH

--
Michael Salamone
Entrek Software, Inc.
http://www.entrek.com


Quote:
> I am trying load a DLL in the \Windows directory using the LoadLibrary
> function. I tried different ways to specify the library name with or
> without the path. It always returns NULL. The error code returned by
> GetLastError() is 126 that means the specified module could not be
> found, but the DLL exists in the \Windows directory.

> The following are the statements I tried:
> HINSTANCE hDLL = LoadLibrary(TEXT("\\Windows\\snmp-mibii.dll"));

> HINSTANCE hDLL = LoadLibrary(TEXT("snmp-mibii.dll"));

> Could anybody give me some hint what may be wrong? Thanks.

> Ruth Hsu
> Intermec Technologies Corporation



Tue, 14 Sep 2004 20:58:57 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. LogonUser always returns error code 126

2. RegSvr32: LoadLibrary error (0x0000007e) 126

3. CreateFile fails, error 126 set, citizens alarmed

4. LogonUser() always returns 126

5. LoadLibrary fails (GetLastError() returns ERROR_OUTOFMEMORY)

6. LoadLibrary generates MessageBox when failing to loadlibrary in Managed C++

7. LoadLibrary fail code 11

8. BSTRs getting cutoff after 126(?) chars

9. system error 126, access database

10. BSTRs getting cutoff after 126(?) chars

11. What is error 126

12. DllRegisterServer abc.dll failed return code :0x80070716

 

 
Powered by phpBB® Forum Software