Solved

LoadLibrary

Posted on 1997-04-22
2
2,322 Views
Last Modified: 2008-03-06
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 Comments
 
LVL 3

Expert Comment

by:rmichels
ID: 1162910
Can you show the code you are using.  How are you specifying the path name of the module (the parameter to LoadLibrary)?  Is the DLL file in the current search path for DLL modules?
0
 
LVL 1

Accepted Solution

by:
shappir earned 50 total points
ID: 1162911
There are several issues to consider when using LoadLibrary:1. The module (DLL) file must reside in a directory where it will be found. Check the documentation for LoadLibrary for information on where Windows looks for the file.2. Beware of name (file name) conflicts with other modules in the system.3. Don’t try to load a 16-bit DLL from a 32-bit program or the other way around.4. If possible, create the DLL using the same language/compiler as the main application. Otherwise you may have naming problems and incompatible library calls.5. If you create your DLL in C/C++ use the same RTL as the main application (single threaded or multi-threaded or mt DLL).6. If the DLL uses __declspec(thread) LoadLibrary will fail. You must use the TLS API instead.Hope this helps, if not try to create the simpleset possible application that just does LoadLibrary and see if it works. If not, post it here.
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

691 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