DosQueryModuleHandle: Difference between revisions
Appearance
mNo edit summary |
mNo edit summary |
||
Line 1: | Line 1: | ||
DosQueryModuleHandle returns the handle of a dynamic link module that was previously loaded. | |||
==Syntax== | ==Syntax== | ||
DosQueryModuleHandle(pszModname, phmod) | |||
==Parameters== | ==Parameters== | ||
;pszModname (PSZ) - input : The address of an ASCIIZ name string containing the dynamic link module name. The file-name extension used for dynamic link libraries is .DLL. | ;pszModname (PSZ) - input : The address of an ASCIIZ name string containing the dynamic link module name. The file-name extension used for dynamic link libraries is .DLL. | ||
; phmod (PHMODULE) - output : The address of a doubleword in which the handle for the dynamic link module is returned. | ;phmod (PHMODULE) - output : The address of a doubleword in which the handle for the dynamic link module is returned. | ||
==Return Code== | ==Return Code== | ||
;ulrc (APIRET) - returns:DosQueryModuleHandle returns one of the following values: | |||
DosQueryModuleHandle returns one of the following values: | * 0 NO_ERROR | ||
* 0 | *123 ERROR_INVALID_NAME | ||
* 123 | |||
==Remarks== | ==Remarks== | ||
The module name must match the name of the module already loaded. Otherwise, an error code is returned. This is a way of testing whether a dynamic link module is already loaded. | |||
The module name must match the name of the module already loaded. Otherwise, an error code is returned. This is a way of testing whether a dynamic link module is already loaded. | |||
==Example Code== | ==Example Code== |
Latest revision as of 08:36, 1 December 2019
DosQueryModuleHandle returns the handle of a dynamic link module that was previously loaded.
Syntax
DosQueryModuleHandle(pszModname, phmod)
Parameters
- pszModname (PSZ) - input
- The address of an ASCIIZ name string containing the dynamic link module name. The file-name extension used for dynamic link libraries is .DLL.
- phmod (PHMODULE) - output
- The address of a doubleword in which the handle for the dynamic link module is returned.
Return Code
- ulrc (APIRET) - returns
- DosQueryModuleHandle returns one of the following values:
- 0 NO_ERROR
- 123 ERROR_INVALID_NAME
Remarks
The module name must match the name of the module already loaded. Otherwise, an error code is returned. This is a way of testing whether a dynamic link module is already loaded.
Example Code
This example attempts to obtain the handle of a dynamic link module. This allows the caller to test whether a given dynamic link module is currently loaded.
#define INCL_DOSMODULEMGR /* Module Manager values */ #define INCL_DOSERRORS /* DOS Error values */ #include <os2.h> #include <stdio.h> int main(VOID) { PSZ ModuleName = "C:\\OS2\\DLL\\DISPLAY.DLL"; /* Module name */ HMODULE ModuleHandle = NULLHANDLE; /* Module handle */ APIRET rc = NO_ERROR; /* Return code */ rc = DosQueryModuleHandle(ModuleName, /* Module to look for */ &ModuleHandle); /* Handle (returned) */ if (rc != NO_ERROR) { printf("DosQueryModuleHandle error: return code = %u\n", rc); return 1; } else { printf ("Module handle = %u\n", ModuleHandle); } rc = DosQueryModuleName (ModuleHandle, /* Module handle to query */ 256L, /* Maximum length of result */ ModuleName); /* Module name returned */ if (rc != NO_ERROR) { printf("DosQueryModuleName error: return code = %u\n", rc); return 1; } else { printf ("Module name = %s\n", ModuleName); } return NO_ERROR; }