gtpc2m1o | C/C++ Language Support User's Guide |
This function obtains a pointer to a dynamic link library (DLL) function.
Format
#include <dll.h> void (* dllqueryfn(dllhandle *dllHandle, char *funcName)) ();
The dllHandle was obtained previously by a successful dllload function call.
Normal Return
The dllqueryfn function returns a pointer to a function (dllHandle) that can be used to call the desired function in a DLL.
Error Return
When the call is not successful, the dllqueryfn function returns NULL and sets errno.
Programming Considerations
For C++ programs, use the external symbol name of the function instead of the function name itself for the funcName parameter. Because of C++ function overloading, a function name may not uniquely define a particular function. For example, in C++, f1(arg1) is a different function than f1(arg1,arg2). To request the particular function in C++, use the external symbol name found in the external symbol cross-reference of a compiler listing.
Examples
The following C language example shows how to use the dllqueryfn function to obtain a pointer to function f1, which is in DLL load module DLLB.
#include <stdio.h> #include <dll.h> int main(void) { dllhandle *handle; char *name="DLLB"; int (*fptr1)(); handle = dllload(name); if (handle == NULL) { printf("failed on dllload of DLLB DLL\n"); exit (-1); } fptr1 = (int (*)()) dllqueryfn(handle,"f1"); if (fptr1 == NULL) { printf("failed on retrieving f1 function\n"); exit (-2); } }
Related Information