LoadExternalModuleEx
- Updated2023-02-21
- 4 minute(s) read
LoadExternalModuleEx
int LoadExternalModuleEx (const char pathname[], const void *callingModuleHandle);
Purpose
![]() |
Note This class of functions is deprecated. National Instruments recommends that you instead use the Windows SDK functions LoadLibrary and GetProcAddress to load external modules. These functions allow you to load Windows DLLs, but not compiled object modules or libraries. |
LoadExternalModuleEx is similar to LoadExternalModule, except that LoadExternalModuleEx allows the external references in object and static library modules loaded from a DLL to be resolved using DLL symbols that have not been exported through the import library. This function behaves identically to LoadExternalModule when loading a DLL import library.
![]() |
Note This function is not supported for 64-bit applications. |
(Linux) Only shared object files (.so) are supported.
When you call LoadExternalModule on an object or library module, external references must be resolved. The external references are resolved using symbols defined in the project or in object, library, or import library modules that have been loaded using LoadExternalModule or LoadExternalModuleEx. This is true even if you call LoadExternalModule from a DLL.
You might want to load an object or library module in a DLL and have the module link back to symbols that you defined in, but did not export from, the DLL. You can do this using LoadExternalModuleEx. You must specify the module handle of the DLL as callingModuleHandle. You can do so by using the LabWindows/CVI predefined variable __CVIUserHInst.
LoadExternalModuleEx first searches the global DLL symbols to resolve external references. LoadExternalModuleEx resolves any remaining unresolved references by searching the symbols defined in the project or exported by object, library, or import library modules that you have already loaded using LoadExternalModule or LoadExternalModuleEx.
LoadExternalModuleEx expects the DLL to contain a table of symbols to use to resolve references. If you create the DLL in LabWindows/CVI, the table is included automatically. If you create the DLL using an external compilerexternal compiler, you must arrange for the table to be included in the DLL. You can do this by creating an include file that includes all the symbols that the table must contain. You can select Build»External Compiler Support in the Workspace window to create an object file that contains the table. You must include the object file in the external compiler project you use to create the DLL.
![]() |
Note You cannot load the same external module using two different calling module handles. The function reports an error if you attempt to load an external module when you have already loaded it under a different module handle. |
LoadExternalModuleEx acts identically to LoadExternalModule in the following cases:
- You pass zero for callingModuleHandle.
- You pass __CVIUserHInst for callingModuleHandle, but you call the function from a file that is in the project or your executable, rather than in a DLL.
LoadExternalModuleEx on Source Files from the Interactive Window
When you load a source file using LoadExternalModuleEx from the Interactive window, you must enable either the Force loaded instrument drivers into Interactive window or Force project files into Interactive window options in the Environment dialog box, depending on whether the source file is in the project or is loaded as an instrument driver. To access the Environment dialog box, select Options»Environment in the Workspace window.
Parameters
Input | ||
Name | Type | Description |
pathname | const char [] | Relative or absolute pathname of the module to load. If pathname is a simple filename, such as module.obj, LoadExternalModuleEx takes the following steps to find the file:
If pathname is a relative pathname with one or more directory paths (such as dir\module.obj), LoadExternalModuleEx creates an absolute pathname by appending the relative pathname to the directory that contains the currently loaded project. (Linux) You must pass the absolute path of the .so file, or the .so file must be in one of the paths specified in the system file /etc/ld.so.conf. Make sure to run the ldconfig command to update the /etc/ld.so.conf file if you add a path. |
callingModuleHandle | const void * | The handle of the DLL in which to resolve names referenced by the external module. In almost all cases, callingModuleHandle is the handle of the DLL in which the call to LoadExternalModuleEx is compiled. Use the default parameter, __CVIUserHInst, to specify the handle of the module that contains the call to LoadExternalModuleEx. A value of 0 indicates your project or executable. If you pass 0, the function behaves identically to LoadExternalModule. |
Return Value
Name | Type | Description | ||||||||||||||||||
moduleID | int | ID of the loaded module.
|
Additional Information
Library: Utility Library
Include file: utility.h
LabWindows/CVI compatibility: LabWindows/CVI 4.0 and later