Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

LoadLibrary

Posted on 1997-04-22
4
Medium Priority
?
2,611 Views
Last Modified: 2008-02-26
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?

0
Comment
Question by:tlsoftware
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 

Accepted Solution

by:
snemanov earned 100 total points
ID: 1162912
Hello,The GetLastError function returns the last occured error/warningand not a result of last called Win32 function.Not all functions call SetLastError(0) when they succeed,
so nothing indicates error in the LoadLibrary.Have You additional symptoms of error?Best regards, Sergey
0
 

Author Comment

by:tlsoftware
ID: 1162913
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?
0
 

Expert Comment

by:snemanov
ID: 1162914
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
0
 

Author Comment

by:tlsoftware
ID: 1162915
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!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question