DosQueryProcType: Difference between revisions
Appearance
m Martini moved page OS2 API:CPI:DosQueryProcType to DosQueryProcType |
mNo edit summary |
||
Line 1: | Line 1: | ||
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. | 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. | ||
Line 7: | Line 6: | ||
#include <os2.h> | #include <os2.h> | ||
HMODULE | HMODULE hmod; /* The handle of the dynamic link module that contains the procedure. */ | ||
ULONG | ULONG ordinal; /* The ordinal number of the procedure whose type is desired. */ | ||
PSZ | PSZ pszName; /* The address of an ASCIIZ name string that contains the procedure name | ||
PULONG | that is being referenced. */ | ||
APIRET | PULONG pulproctype; /* The address of a ULONG in which the procedure type is returned. */ | ||
APIRET ulrc; /* Return Code. */ | |||
ulrc = DosQueryProcType(hmod, ordinal, pszName, pulproctype); | ulrc = DosQueryProcType(hmod, ordinal, pszName, pulproctype); | ||
</PRE> | |||
==Parameters== | ==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. | |||
; ordinal (ULONG) - input : The ordinal number of the procedure whose type is desired. | :If the ordinal number is nonzero, pszName is ignored. | ||
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. | |||
; 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. | ; 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: | |||
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== | ==Return Code== | ||
ulrc (APIRET) - returns | ulrc (APIRET) - returns | ||
DosQueryProcType returns one of the following values: | DosQueryProcType returns one of the following values: | ||
* 0 NO_ERROR | |||
* 6 ERROR_INVALID_HANDLE | |||
* 123 ERROR_INVALID_NAME | |||
* 182 ERROR_INVALID_ORDINAL | |||
==Remarks== | ==Remarks== | ||
DosQueryProcType returns the type of the specified procedure within a dynamic link module. | DosQueryProcType returns the type of the specified procedure within a dynamic link module. | ||
Line 48: | Line 40: | ||
The type returned indicates whether the specified procedure is a 16-bit or 32-bit callable procedure. | The type returned indicates whether the specified procedure is a 16-bit or 32-bit callable procedure. | ||
If return code ERROR_INVALID_HANDLE is received, issue DosLoadModule and then issue DosQueryProcType again. | If return code ERROR_INVALID_HANDLE is received, issue [[DosLoadModule]] and then issue DosQueryProcType again. | ||
==Example Code== | ==Example Code== | ||
This example loads the dynamic link module | This example loads the dynamic link module <tt>DISPLAY.DDL</tt>, queries its address and type, and finally frees it. | ||
<PRE> | <PRE> | ||
#define INCL_DOSMODULEMGR /* Module Manager values */ | #define INCL_DOSMODULEMGR /* Module Manager values */ | ||
#define INCL_DOSERRORS /* Error values */ | #define INCL_DOSERRORS /* Error values */ | ||
Line 105: | Line 97: | ||
} | } | ||
</PRE> | </PRE> | ||
==Related Functions== | ==Related Functions== | ||
* [[ | *[[DosFreeModule]] | ||
* [[ | *[[DosLoadModule]] | ||
* [[ | *[[DosQueryModuleName]] | ||
* [[ | *[[DosQueryProcAddr]] | ||
[[Category: | [[Category:Dos]] |
Revision as of 03:37, 6 January 2017
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
#define INCL_DOSMODULEMGR #include <os2.h> HMODULE hmod; /* The handle of the dynamic link module that contains the procedure. */ ULONG ordinal; /* The ordinal number of the procedure whose type is desired. */ PSZ pszName; /* The address of an ASCIIZ name string that contains the procedure name that is being referenced. */ PULONG pulproctype; /* The address of a ULONG in which the procedure type is returned. */ APIRET ulrc; /* Return Code. */ ulrc = 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
DosQueryProcType 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.
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; }