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
2
Medium Priority
?
2,332 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 100 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
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.

636 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