dllqueryvar() — Obtain a pointer to a dynamic link library variable
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
C Library | both |
Format
#include <dll.h>
void* dllqueryvar(dllhandle *dllHandle, const char *varName);
General description
Obtains a pointer to a dynamic link library (DLL) variable (varName). It uses the dllHandle returned from a previous successful call to dllload() for input. varName represents the name of an exported variable from the DLL. It must be a character string terminated with the NULL character.
This function is not available under SPC, MTF and CSP environments.
Returned value
If successful, dllqueryvar() returns a pointer to a variable in the storage of the DLL.
If unsuccessful, dllqueryvar() returns NULL and sets errno.
Usage notes
- More detailed diagnostic information is available through the _EDC_DLL_DIAG environment variable, and the Language Environment® DLL Failure control block (CEEDLLF) chain.
Example
CELEBDL3
/* CELEBDL3
The following example shows how to use dllqueryvar() to obtain a
pointer to a variable, var1, that is in DLL load module stream.
*/
#include <stdio.h>
#include <dll.h>
int main() {
dllhandle *handle;
char *name="stream";
int (*fptr1)(int);
int *ptr_var1;
int rc=0;
handle = dllload(name);
if (handle == NULL) {
perror("failed on dllload of stream DLL");
exit(-1);
}
fptr1 = (int (*)(int)) dllqueryfn(handle,"f1");
/* retrieving f1 function */
if (fptr1 == NULL) {
perror("failed on retrieving f1 function");
exit(-2);
}
ptr_var1 = dllqueryvar(handle,"var1");
if (ptr_var1 == NULL) {
perror("failed on retrieving var1 variable");
exit(-3);
}
}