DosQueryProcType
From EDM2
Returns the type of the specified procedure within a dynamic link module. The type returned indicates whether the specified procedure is a 16-bit or 32-bit callable procedure.
Syntax
DosQueryProcType(hmod, ordinal, pszName, pulproctype)
Parameters
- hmod (HMODULE) - input
- The handle of the dynamic link module that contains the procedure.
- ordinal (ULONG) - input
- The ordinal number of the procedure whose type is desired.
- If the ordinal number is nonzero, pszName is ignored.
- pszName (PSZ) - input
- The address of an ASCIIZ name string that contains the procedure name that is being referenced.
- Calls to DosQueryProcType for entries within the DOSCALLS module are supported for ordinal references only. References to the DOSCALLS module by name strings are not supported, and will return an error. Dynamic link ordinal numbers for DOSCALLS routines are resolved by linking with OS2386.LIB.
- pulproctype (PULONG) - output
- The address of a ULONG in which the procedure type is returned.
- The value returned in this field is one of the following:
- 0 - PT_16BIT - Procedure is 16-bit.
- 1 - PT_32BIT - Procedure is 32-bit.
Return Code
- ulrc (APIRET) - returns
- DosQueryProcType returns one of the following values:
- 0 NO_ERROR
- 6 ERROR_INVALID_HANDLE
- 123 ERROR_INVALID_NAME
- 182 ERROR_INVALID_ORDINAL
Remarks
If return code ERROR_INVALID_HANDLE is received, issue DosLoadModule and then issue DosQueryProcType again.
Example Code
This example loads the dynamic link module DISPLAY.DDL, queries its address and type, and finally frees it.
#define INCL_DOSMODULEMGR /* Module Manager values */ #define INCL_DOSERRORS /* Error values */ #include <os2.h> #include <stdio.h> int main(VOID){ PSZ ModuleName = "C:\\OS2\\DLL\\DISPLAY.DLL"; /* Name of module */ UCHAR LoadError[256] = ""; /* Area for Load failure information */ HMODULE ModuleHandle = NULLHANDLE; /* Module handle */ PFN ModuleAddr = 0; /* Pointer to a system function */ ULONG ModuleType = 0; /* Module type */ APIRET rc = NO_ERROR; /* Return code */ rc = DosLoadModule(LoadError, /* Failure information buffer */ sizeof(LoadError), /* Size of buffer */ ModuleName, /* Module to load */ &ModuleHandle); /* Module handle returned */ if (rc != NO_ERROR) { printf("DosLoadModule error: return code = %u\n", rc); return 1; } else { printf("Module %s loaded.\n", ModuleName); } /* endif */ rc = DosQueryProcAddr(ModuleHandle, /* Handle to module */ 1L, /* No ProcName specified */ NULL, /* ProcName (not specified) */ &ModuleAddr); /* Address returned */ if (rc != NO_ERROR) { printf("DosQueryProcAddr error: return code = %u\n", rc); return 1; } else printf("Address of module is 0x%x.\n", ModuleAddr); rc = DosQueryProcType(ModuleHandle, /* Handle to module */ 1L, /* Indicate no ProcName given */ NULL, /* ProcName (not specified) */ &ModuleType); /* Type 0=16-bit 1=32-bit */ if (rc != NO_ERROR) { printf("DosQueryProcType error: return code = %u\n", rc); return 1; } else printf("This is a %s module.\n", ( ModuleType ? "32-bit" : "16-bit")); rc = DosFreeModule(ModuleHandle); if (rc != NO_ERROR) { printf("DosFreeModule error: return code = %u\n", rc); return 1; } else printf("Module %s freed.\n", ModuleName); return NO_ERROR;
}