gtpc2m1pC/C++ Language Support User's Guide

dllqueryvar-Obtain a Pointer to a DLL Variable

This function obtains a pointer to a dynamic link library (DLL) variable.

Format

#include <dll.h>
void* dllqueryvar(dllhandle *dllHandle, char *varName);

dllHandle
A pointer to the dllhandle structure that is described in the dll.h header file.

The dllHandle was obtained previously by a successful dllload function call.

varName
A pointer to the character string ending with the NULL ('\0') character string that represents the name of an exported variable from the DLL.

Normal Return

The dllqueryvar function returns a pointer to a variable in the storage of the DLL if the call is successful.

Error Return

When the call is not successful, the dllqueryvar function returns NULL and sets errno.

Programming Considerations

None.

Examples

The following example shows how to use the dllqueryvar function to obtain a pointer to variable var1, which is in DLL load module DLLB.

#include <stdio.h>
#include <dll.h>
 
int main(void) {
  dllhandle *handle;
  char *name="DLLB";
  int *ptr1_var1;
 
  handle = dllload(name);
  if (handle == NULL) {
      printf("failed on dllload of DLLB DLL\n");
      exit (-1);
  }
 
  ptr_var1 = dllqueryvar(handle,"var1");
  if (ptr_var1 == NULL) {
      printf("failed on retrieving var1 variable\n");
      exit (-3);
  }
}

Related Information