Re: Loadlibrary returns err.lastdellerror 127



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 ...

.



Relevant Pages

  • Re: running a service/driver/application upon startup
    ... debug version of the image is too large to load onto the device. ... I ran dumpbin/exports on the finger dll and saw the required function names: ... > theories as to why it's not getting loaded but just doing 'services load ...
    (microsoft.public.windowsce.embedded)
  • Re: Dynamic DLL
    ... I have a solution where I load the DLL dynamically (using ... LoadLibrary/FreeLibrary) but I have the DLL declarations in the VBA code ... city) and then call the functions declared in the Declare... ...
    (microsoft.public.office.developer.vba)
  • Re: Unable to load custom driver on WinCE 6
    ... I'm trying to make and load a simple DLL on WinCE 6 by following the ... I've made a subproject at PB project to include the simple DLL ... At the target device, the mydriver.dll file is in the Windows ... I wrote a simple application to load the driver dynamically ...
    (microsoft.public.windowsce.embedded)
  • Re: Cannot activate sbcl
    ... but I think what happens is that Windows sees that your executable has a DATA section that might overlap a DLL's address space then it would reallocate that DLL to different address space. ... VirtualAlloc dynamically in your code is that your program and all its ... What can be done here is to have many tiny executables with different BSS sections in them, which then load a bigger executable in the form of a DLL. ...
    (comp.lang.lisp)
  • Re: Loadlibrary returns err.lastdellerror 127
    ... the resulting .exe I load all the dependant DLL's first (there are ... Assuming this is a 'regular' Dll and not an ActiveX Dll. ... you do NOT need to 'load' all the dependant Dlls. ... If you absolutely have to use the LoadLibrary API show your calling code ...
    (microsoft.public.vb.general.discussion)