LabWindows/CVI

Content Type
Programming Language
Current manual

GetExternalModuleAddrEx

GetExternalModuleAddrEx

void *GetExternalModuleAddrEx (int moduleID, const char name[], int *status, int options, char buffer[], unsigned int bufferSize);

Purpose

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

Obtains the address of an identifier in a module that was loaded using LoadExternalModule. The identifier must be either a variable or function name defined globally in the external module.

Note Note  This function is not supported for 64-bit applications.

If this function succeeds, it returns the address of the variable or function in the module and sets the status parameter to zero. If this function fails, it returns NULL and sets the status parameter to a negative error code.

Use GetExternalModuleAddrEx to get the list of undefined symbols if the function fails because there are undefined symbols.

Note   For global variables exported by a DLL, you have to use the name of the import symbol. For example, if the DLL exports a variable global, you have to pass __imp_global. In this case GetExternalModuleAddrEx returns a pointer to a pointer to the variable.

Even though you can access global variables exported by a DLL through GetExternalModuleAddrEx as described above, the preferred mechanism is to provide a pair of Set and Get functions.

Parameters

Input
Name Type Description
moduleID int The value returned by LoadExternalModule.
name const char [] The name of the identifier whose address is to be obtained from the external module.
options int Pass GETEXTMODADDR_OPTIONS_LIST_UNDEFINED to obtain a list of the undefined symbols if this function fails because of undefined symbols.

Pass 0 if you do not want the list of undefined symbols.
bufferSize unsigned int The size, in bytes, of the buffer passed in the buffer parameter.
Output
Name Type Description
status int The status of the call to GetExternalModuleAddrEx.

If GetExternalModuleAddrEx succeeds, it sets this parameter to zero. If GetExternalModuleAddrEx fails, it sets this parameter to a negative error code.

Value Description
0 Success.
-1 Out of memory.
-4 Invalid file format.
-5 Undefined references.
-8 Cannot open file.
-9 Invalid module id.
-10 Identifier not defined globally in module.
-20 DLL missing function, for example, a function is in the import library but not in the DLL.
-25 DLL initialization failed, for example, a DLL file not found.
buffer char [] The buffer in which data is returned. The contents of the buffer are determined by the options parameter.

If you pass GETEXTMODADDR_OPTIONS_LIST_UNDEFINED in the options parameter, this buffer is filled with the list of undefined symbols if the function fails because there are undefined symbols. Use a comma to delimit the symbols.

If the list of symbols does not fit in the buffer, the list is truncated to the size of the buffer.

Return Value

Name Type Description
address void * The address of the identifier in the external module.

If the identifier is a function, you normally assign the return value to a function pointer. If the function has a calling convention that differs from the default calling convention, you must include the calling convention in the declaration of the function pointer variable. Assume that the following function is declared in the external module:

int __stdcall SetADouble (double d);


If the default calling convention for this example is __cdecl, declare the function pointer as follows:

int (__stdcall * SetADouble_FnPtr)(double) = NULL;


To determine the default calling convention, select Options»Build Options in the Workspace window.

Additional Information

Library: Utility Library

Include file: utility.h

LabWindows/CVI compatibility: LabWindows/CVI 5.5 and later

Was this information helpful?