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
Solved

LoadLibrary

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

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…
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 goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

808 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