Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
DosGetProcAddr (1.2)
◄Function Group► ◄Overview► ◄Up► ◄Next► ◄Previous►
────────────────────────────────────────────────────────────────────────────
#define INCL_DOSMODULEMGR
USHORT DosGetProcAddr(hmod, pszProcName, ppfnProcAddress)
HMODULE hmod; /* handle of module */
PSZ pszProcName; /* pointer to module-name string */
PPFN ppfnProcAddress; /* pointer to variable for procedure address */
The DosGetProcAddr function retrieves the address of a procedure in a
specified dynamic-link module. This address can then be used to call the
procedure.
Parameter Description
────────────────────────────────────────────────────────────────────────────
hmod Identifies the dynamic-link module. This handle must have
been created previously by using the DosLoadModule or
DosGetModName function.
pszProcName Points to a null-terminated string that specifies the
procedure name to retrieve. If this string starts with a
number sign (#), the remaining part of the string is
treated as an ASCII ordinal. Alternately, if the selector
portion of the pointer is zero, the offset portion of the
pointer is an explicit entry number (an ordinal) within the
dynamic-link module.
ppfnProcAddress Points to the variable that receives the procedure
address.
Return Value
The return value is zero if the function is successful. Otherwise, it is an
error value, which may be one of the following:
ERROR_INTERRUPT
ERROR_INVALID_HANDLE
ERROR_PROC_NOT_FOUND
Comments
Although the DosGetProcAddr function can be used to retrieve procedure
addresses from the DOSCALLS dynamic-link module, these procedures are
available through ordinal values only. If you attempt to retrieve a
procedure address from the DOSCALLS module by using a procedure name,
DosGetProcAddr returns an error.
Example
This example calls the DosLoadModule function to load the dynamic-link
module qhdll.dll. It then calls the DosGetProcAddr function to retrieve the
address of the BOXMESSAGE function that is defined in the module and calls
the DosFreeModule function to free the dynamic-link module. (This example is
accurate if qhdll.dll exists in a directory defined by the libpath parameter
of the config.sys file, and if qhdll.dll contains the BOXMESSAGE function
that uses the Pascal calling convention.)
UCHAR szFailName[CCHMAXPATH];
HMODULE hmod;
VOID (PASCAL FAR *pfnBoxMsg) (PSZ, BYTE, BYTE, SHANDLE, SHANDLE, BOOL);
DosLoadModule(szFailName, sizeof(szFailName), "qhdll", &hmod);
DosGetProcAddr(hmod, /* module handle */
"BOXMESSAGE", /* name of function */
&pfnBoxMsg); /* variable for function address */
pfnBoxMsg("Hello World", 0x30, 1, 0, 0);
DosFreeModule(hmod);
See Also
DosFreeModule, DosGetModName, DosLoadModule
♦