LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

call dll function from static library

I'm using TestExec. When I want to run a test TestExec runs a
sequence file and the sequence file causes TestExec to load a library
file that has the functions that will be used for the test. I believe
the library file is being loaded with LoadExternalModule(). The
library file calls a dll that I've created to handle rs485 token
passing. The library loads the dll with LoadExternalModule(). So far
so good. However when I try to get a function address from the dll
using GetExternalModuleAddr() I get an error -25 (intialization
failure) or as the windows function GetLastError() puts it, error 126
The specified module could not be found. I know the dll is good
because I can create a simple labwindows application with a couple of

command buttons for LoadExternalModule() and GetExternalModuleAddr()
and I can load and run the dll functions just fine. It's only when I
try call the dll from an externally loaded library that I run into
problems. How can I call a dll function from an externally loaded
library? The solution must be in modifying the library file or the
dll. Changing TestExec is not an option for me. Help? Can I bypass
the CVI functions altogether and use windows functions LoadLibrary()
and GetProcAddress() to load and run the dll functions instead? What
is the proper way to do this? I tried this and got an unresolved
references error. Any help would be excellent.
0 Kudos
Message 1 of 3
(4,141 Views)
LoadExternalModule is NOT for use with DLLs directly. It's for LIB and OBJ files. You could use it with the DLL import library (.LIB) file, but not on a DLL directly. See the help for the LoadExternalModule function.

You can use the LoadLibrary()/GetProcAddress() method to load the library. This is frequently used by CVI programmer's and is the only alternative to using a import library (statically linked or loaded through LoadExternalModule).

Best Regards,

Chris Matthews
National Instruments
Message 2 of 3
(4,141 Views)
I figured out that I can use use windows functions LoadLibrary()and
GetProcAddress() to load and run the dll functions instead of cvi
functions LoadExternalModule() and GetExternalModuleAddr(). What I
did wrong before was I put the dll in the folder my library file was
in and I should have put it in the folder TestExec is in since
TestExec is the application the dll is being mapped into.

aachess@yahoo.com (Kevin Houston) wrote in message news:...
> I'm using TestExec. When I want to run a test TestExec runs a
> sequence file and the sequence file causes TestExec to load a library
> file that has the functions that will be used for the test. I believe
> the library file is being loaded with LoadExternalModule().
The
> library file calls a dll that I've created to handle rs485 token
> passing. The library loads the dll with LoadExternalModule(). So far
> so good. However when I try to get a function address from the dll
> using GetExternalModuleAddr() I get an error -25 (intialization
> failure) or as the windows function GetLastError() puts it, error 126
> The specified module could not be found. I know the dll is good
> because I can create a simple labwindows application with a couple of
> command buttons for LoadExternalModule() and GetExternalModuleAddr()
> and I can load and run the dll functions just fine. It's only when I
> try call the dll from an externally loaded library that I run into
> problems. How can I call a dll function from an externally loaded
> library? The solution must be in modifying the library file or the
> dll. Changing TestExec is not an option for me. Help? Can I bypass
> the CVI functions altogether and use windows functions LoadLibrary()
> and GetProcA
ddress() to load and run the dll functions instead? What
> is the proper way to do this? I tried this and got an unresolved
> references error. Any help would be excellent.
0 Kudos
Message 3 of 3
(4,141 Views)