Chapter 8 Utility Library
© National Instruments Corporation 8-51 LabWindows/CVI Standard Libraries
• You can call RunExternalModule. This requires that the module contain a function with
a pre-defined name and prototype. The function serves as the entry point to the module. See
RunExternalModule for more information.
LoadExternalModule can also be used on a source file (.c) that is part of the current
project or a source file that has been loaded as the program for an instrument module. This
allows you to develop your module in source code form and test it using the LabWindows/CVI
debugging capabilities. After you have finished testing your module and compiled it into an
external object or library file, you need to make no modifications to your application source code
other than to change the pathname in the call to LoadExternalModule.
Avoid calling LoadExternalModule on a file in the project when you plan to link your
program in an external compiler. The LabWindows/CVI Utility library does not know the
locations of symbols in executables or DLLs linked in external compilers. You can provide this
information by using the Other Symbols section of the External Compiler Support dialog box
(in the Build menu of the LabWindows/CVI Project window) to create an object module
containing a table of symbols you want to find using GetExternalModuleAddr. If you use
this method, you should pass the empty string ("") to LoadExternalModule for the module
pathname.
If successful, LoadExternalModule returns an integer module ID which can later be passed
to RunExternalModule, GetExternalModuleAddr, and UnloadExternalModule.
If unsuccessful, LoadExternalModule returns a negative error code.
Resolving External References from Object and Static Library Files on Windows 95/NT
There is an important difference between loading an object or static library module and loading a
DLL via an import library. DLLs are prelinked, that is, when an DLL is loaded, no external
references need to be resolved. Object and static library modules, on the other hand, do have
external references that need to be resolved. LoadExternalModule resolves them using
symbols defined in the project or in object, static library, or import library modules that have
already been loaded using LoadExternalModule. This is true even when you call
LoadExternalModule from a DLL. LoadExternalModule does not use symbols in a
DLL to resolve external references unless those symbols have been exported in the import
library.
When you load an object or library module from a DLL, you may want external references to be
resolved through global symbols in the DLL that have not been exported in the import library. If
this is your intention, you must call LoadExternalModuleEx rather than
LoadExternalModule.
Using This Function
pathname may be a relative or absolute pathname. If it is a simple file name (such as
module.obj), LoadExternalModule attempts to find the file as follows.
1. It first looks for the file in the project list.
2. It then looks for the file in the directory that contains the currently loaded project.