DosQueryModuleHandle: Difference between revisions
Appearance
m Martini moved page OS2 API:CPI:DosQueryModuleHandle to DosQueryModuleHandle |
mNo edit summary |
||
Line 1: | Line 1: | ||
Returns the handle of a dynamic link module that was previously loaded. | Returns the handle of a dynamic link module that was previously loaded. | ||
Line 12: | Line 11: | ||
ulrc = DosQueryModuleHandle(pszModname, phmod); | ulrc = DosQueryModuleHandle(pszModname, phmod); | ||
</PRE> | |||
==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. | ||
; 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 | ulrc (APIRET) - returns | ||
DosQueryModuleHandle returns one of the following values: | DosQueryModuleHandle returns one of the following values: | ||
* 0 NO_ERROR | * 0 NO_ERROR | ||
* 123 ERROR_INVALID_NAME | * 123 ERROR_INVALID_NAME | ||
Line 65: | Line 62: | ||
return NO_ERROR; | return NO_ERROR; | ||
} | } | ||
</PRE> | |||
==Related Functions== | ==Related Functions== | ||
* [[ | *[[DosFreeModule]] | ||
* [[ | *[[DosLoadModule]] | ||
* [[ | *[[DosQueryModuleName]] | ||
[[Category: | [[Category:Dos]] |
Revision as of 04:44, 6 January 2017
Returns the handle of a dynamic link module that was previously loaded.
Syntax
#define INCL_DOSMODULEMGR #include <os2.h> PSZ pszModname; PHMODULE phmod; APIRET ulrc; /* Return Code. */ ulrc = 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
DosQueryModuleHandle returns the handle of a dynamic link module that was previously 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
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; }