Re: Loadlibrary returns err.lastdellerror 127
- From: Prescott <pchartier@xxxxxxxxx>
- Date: Mon, 10 Sep 2007 10:30:18 -0700
On Sep 10, 12:24 pm, "Ralph" <nt_consultin...@xxxxxxxxx> wrote:
"Prescott" <pchart...@xxxxxxxxx> wrote in message
news:1189439000.229431.302070@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Using VB 6, I'm trying to load an in house created DLL (created in
Visual Fortran) using load library, it loads in the ide but not with
the resulting .exe I load all the dependant DLL's first (there are
two) and then the in house created DLL. err.LastDLLError returns 127
("specified module not found" I assume). Any ideas?
Prescott ...
Assuming this is a 'regular' Dll and not an ActiveX Dll. (Else you just need
to register it.)
First, you can simplify the process by not using the LoadLibrary() API. Use
the Declare Function/Sub Statement:
Declare [ Sub | Function ] FunctionName Lib "dllname.dll" Alias
"ExportedName" ([Argument As DataType]* ) [ As DataType ]
Second, you do NOT need to 'load' all the dependant Dlls. Windows will take
care of it when it loads the primary Dll.
Third, never trust the LastDLLError value unless you KNOW the Dll returns a
"LastError". Not all Win Dlls do and your Dll will NOT either unless you
programmed it to. So the error can be a random value or a value passed up
from a dependent component.
If you absolutely have to use the LoadLibrary API show your calling code
both for the load and the call on the procedure.
-ralph
The called DLL was created as a "Win32 DLL" and I've also tried it as
a "Fortran Windows DLL" (or some such). I used the object viewer to
determine that it does have the correct load points for a Windows
DLL. When using regsvr32 to register the DLL, it fails with the
message "The specified module was not found" (or some such) which
according to everything I've read on the user groups indicates that it
cannot find a supporting DLL both of which are in the same directory
and I've tried putting that folder on the path as well, no luck.
Actually the declare statements are there as well. I've been playing
around with the code and I figured that it wouldn't hurt to load the
DLLs manually. The DLLs in question are in the same directory as the
compiled/linked executable. All the functions in the in house created
DLL accept two parameters, the first is a array of strings and the
second is a long (the number of elements in the array). The declare
statement looks something like this (security issues prevent me from
posting the actual code):
Declare Function foo Lib "MyDll.dll" ( ByRef StringArray() as String,
ByVal NumElements as Long)
I've created a sub main and marked that as the start point. In there
I use LoadLibrary to load all the DLLs, the dependant DLLs first and
then the DLL that contains the functions that are declared (about 10
or twelve of them) and then show the main form. I've tried changing
the path environment variable to point to the location of the DLL in
question with the same result, the DLL loads in the IDE, but when
running the exe it does not load, the handle returned for the in house
created DLL is zero. Whren running the application, I get a VB error
53, MyDll.DLL not found. I am logged on as an administrator on the
machine and have access to everything. After each loadlibrary
statement I check the returned handle value for zero, if it is zero I
then display the err.LastDLLError value, which in this case is 127.
I've run out of ideas and I've serached the user groups extensively
for information. Any help would be greatly appreciated.
Prescott ...
.
- Follow-Ups:
- Re: Loadlibrary returns err.lastdellerror 127
- From: Michael C
- Re: Loadlibrary returns err.lastdellerror 127
- From: dpb
- Re: Loadlibrary returns err.lastdellerror 127
- From: Ken Halter
- Re: Loadlibrary returns err.lastdellerror 127
- From: Ralph
- Re: Loadlibrary returns err.lastdellerror 127
- References:
- Loadlibrary returns err.lastdellerror 127
- From: Prescott
- Re: Loadlibrary returns err.lastdellerror 127
- From: Ralph
- Loadlibrary returns err.lastdellerror 127
- Prev by Date: Re: issue with vb6 browser form
- Next by Date: Re: unmanaged use of IAudioEndpointVolume::SetMasterVolumeLevel
- Previous by thread: Re: Loadlibrary returns err.lastdellerror 127
- Next by thread: Re: Loadlibrary returns err.lastdellerror 127
- Index(es):
Relevant Pages
|