Link to home
Start Free TrialLog in
Avatar of tlsoftware
tlsoftware

asked on

LoadLibrary

I am having some difficulty with the LoadLibrary function in the Windows
API.  When I try and load a dll (which I made) GetLastError returns 126 but the function DOES NOT return NULL.
The documentation identifies this error as RROR_MOD_NOT_FOUND.  I was
certain I was specifying the correct name.  So I considered maybe my DLL
was improper in some way.  So I tried to load another dll (one that I
randomly selected from the windows directory) and GetLastError return 31
OR_GEN_FAILURE.  If I attempt to link the import library for my DLL to
the exectuble then everything works great.  So I am pretty certain my
DLL works fine.  For my purposes I need to dynamically load my DLL
however and I havn't been able to get LoadLibrary to work on my DLL or
any other.  Does anybody have any ideas?

ASKER CERTIFIED SOLUTION
Avatar of snemanov
snemanov

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tlsoftware
tlsoftware

ASKER

I considered that possibility so I called SetLastError(0) just before calling the LoadLibrary function.  It still returned error  126.  And a later call to GetProcAddress fails.  Any ideas?
Some ideas, tips and assumptions:1) There are many calls of Win32 functions into LoadLibrary() so the previous assumption still actual.2) I guess You have used wrong NAME MANGLING of the function name in the GetProcAddress.If you wish I'll not guess, just print the appropriate code fragment.3) If the previous bullet not works: Can You link that DLL staticly for debug purposes ?(At the load time with the export library). If You have a linking error when you try to use the same function that you have tried to load by GetProcAddress then the problem in the linking method.4) There is teoretically possible an error without NULL returning but I NOT BELIEVE IN THAT POSSIBILITY. It should be the last possible assumption.Best wishes, Sergey
Ok I got it working; thanx for the help!  It was the name mangling in GetProcAddress.  The LoadLibrary function was actually working (but still returned error 126 which was misleading).  So I feel dumb.  Anyways thanx for the help!