Jump to content

DosQueryProcAddr

From EDM2

DosQueryProcAddr

Syntax

rc = DosQueryProcAddr( hMod, ulOrdinal, pszProcName, pProcAddr );

Parameters

HMODULE hMod (input)
Handle for the module to be queried (from DosLoadModule).
ULONG ulOrdinal (input)
Ordinal number for the sought process. If 0 then pszProcName is used.
PSZ pszProcName (input)
Pointer to string containing the sought processes name. Not case sensitive.
PFN* pProcAddr (output)
Address of a function pointer, which will contain the address of the procedure.

Returns

APIRET rc
Indicates if any error occured.
0 NO_ERROR
6 ERROR_INVALID_HANDLE
123 ERROR_INVALID_NAME
65079 ERROR_ENTRY_IS_CALLGATE

Include Info

  1. define INCL_DOSMODULEMGR
    #include <os2.h>

Usage Explanation

DosQueryProcAddr is used to find the address of a process in a dynamic link module.

Relevant Structures

Gotchas

Sample Code

void (* my_dll_function)(int, char*);  /* Pointer to process */
HMODULE hmod;
APIRET rc = 0;

/* Load DLL and get hmod with DosLoadModule*/ 

/* Get address for process in DLL */
rc = DosQueryProcAddr(hmod, 0, "MY_DLL_FUNCTION", (PFN *) my_dll_function);
if(rc) {   /* Failure? */
   printf("Error. Cannot get the address for my_dll_function. DosQueryProcAddr returned %d.\n",rc);
   return(-1);
}

/* Call my_dll_function */
my_dll_function(4711,"Hello World!\n");

See Also

DosLoadModule, DosFreeModule