LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

how to use LoadExternalModule and GetExternalModuleAddr to get functions' address in DLL

I have a third-party DLL (e.g., xxx.dll, together with xxx.h and xxx.lib), which is compiled under VC++ environment. Now I want to use LabWindow/CVI7.1 to write a program which need to call some functions in the DLL. I want to use LoadExternalModule and GetExternalModuleAddr to get the address of those functions. The specification of LoadExternalModule says that I can use only the xxx.lib filename as an input. But if I do so, GetExternalModuleAddr fails. And the third argument of GetExternalModuleAddr, status, is -25, which means "DLL initialization failed, for example, DLL file not found." However, I actually put the dll file at the same directory as the executable file's. What did I do wrong?

What shall I do to use LoadExternalModule and GetExternalModuleAddr to get the DLL functions' address? Or, is there any other method to get the DLL functions' address?

Thanks in advance

Laoyun
0 Kudos
Message 1 of 2
(3,776 Views)
See some tips on using DLLs here.
Why do you want to use LoadExternalModule?
See an example of using SDK functions on using the SDK functions LoadLibrary and GetProcAddress here.

The easiest way to use DLL fucntions is to statically link the DLL (add the DLL's .LIB file to your project and #include the .h file for the exported functions). If you #include the .h file for the exported functions in all your .c files, you can call a DLL function directly from any .c file.

The benefit of using LoadLibrary and FreeLibrary is conserving memory. You can LoadLibrary when you need the functions, then FreeLibrary when you don't. But if you're not using a bunch of different DLL's and you want the functions available all the time, static linking can be a lot easier.

Look at the sample programs that ship with CVI. They don't use LoadLibrary.
...\CVI\samples\dll\simple\cvi\readme.txt
...\CVI\samples\dll\simple\cvi\mydll.prj
...\CVI\samples\dll\simple\cvi\simple.prj
0 Kudos
Message 2 of 2
(3,768 Views)