Solved

LoadLibrary

Posted on 1997-04-22
2
2,319 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C++ BOOL WINAPI ReadFile fails on windows 10 when reading from USB cable 9 520
Excel/Word Add-in in what language? 5 144
C++ help/ Toy problem 19 56
Gaming Software 1 30
Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

726 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