Jump to content

DosQueryModuleName: Difference between revisions

From EDM2
Created page with "==Description== Returns the fully-qualified drive, path, file name, and extension associated with the referenced module handle. ==Syntax== <PRE> #define INCL_DOSMODULEMGR #in..."
 
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==Description==
Returns the fully-qualified drive, path, file name, and extension associated with the referenced module handle.
Returns the fully-qualified drive, path, file name, and extension associated with the referenced module handle.


==Syntax==
==Syntax==
<PRE>
  DosQueryModuleName(hmod, cbName, pch)
#define INCL_DOSMODULEMGR
#include <os2.h>
 
HMODULE    hmod;    /*  The handle of the dynamic link module that is being referenced. */
ULONG      cbName;  /*  The maximum length of the buffer, in bytes, where the name will be stored. */
PCHAR      pch;    /*  The address of the buffer where the file specification of the module are returned. */
APIRET    ulrc;    /* Return Code. */
 
ulrc = DosQueryModuleName(hmod, cbName, pch);


</PRE>
==Parameters==
==Parameters==
; hmod (HMODULE) - input : The handle of the dynamic link module that is being referenced.
;hmod ([[HMODULE]]) - input: The handle of the dynamic link module that is being referenced.
This handle is provided in the DI register on entry to a module, or on the initialization entry to a dynamic link routine.  
:This handle is provided in the DI register on entry to a module, or on the initialization entry to a dynamic link routine.
;cbName ([[ULONG]]) - input: The maximum length of the buffer, in bytes, where the name will be stored.
;pch ([[PCHAR]]) - output: The address of the buffer where the file specification of the module are returned.


; cbName (ULONG) - input : The maximum length of the buffer, in bytes, where the name will be stored.
; pch (PCHAR) - output : The address of the buffer where the file specification of the module are returned.
==Return Code==
==Return Code==
ulrc (APIRET) - returns
;ulrc (APIRET) - returns:DosQueryModuleName returns one of the following values:
 
* 0 NO_ERROR
DosQueryModuleName returns one of the following values:
* 6 ERROR_INVALID_HANDLE
 
*24 ERROR_BAD_LENGTH
* 0     NO_ERROR  
* 6     ERROR_INVALID_HANDLE
* 24   ERROR_BAD_LENGTH


==Remarks==
==Remarks==
DosQueryModuleName returns the fully qualified drive, path, file name, and extension associated with the referenced module handle.
DosQueryModuleName returns the fully qualified drive, path, file name, and extension associated with the referenced module handle.


If the buffer is not large enough, an error is returned.  
If the buffer is not large enough, an error is returned.


==Example Code==
==Example Code==
Line 70: Line 55:
   return NO_ERROR;
   return NO_ERROR;
}
}
</PRE>


</PRE>
==Related Functions==
==Related Functions==
* [[OS2 API:CPI:DosFreeModule|osFreeModule]]
* [[DosFreeModule]]
* [[OS2 API:CPI:DosLoadModule|DosLoadModule]]
* [[DosLoadModule]]
* [[OS2 API:CPI:DosQueryModuleHandle|DosQueryModuleHandle]]
* [[DosQueryModuleHandle]]
 


[[Category:The OS/2 API Project]]
[[Category:Dos]]

Latest revision as of 20:27, 13 April 2024

Returns the fully-qualified drive, path, file name, and extension associated with the referenced module handle.

Syntax

DosQueryModuleName(hmod, cbName, pch)

Parameters

hmod (HMODULE) - input
The handle of the dynamic link module that is being referenced.
This handle is provided in the DI register on entry to a module, or on the initialization entry to a dynamic link routine.
cbName (ULONG) - input
The maximum length of the buffer, in bytes, where the name will be stored.
pch (PCHAR) - output
The address of the buffer where the file specification of the module are returned.

Return Code

ulrc (APIRET) - returns
DosQueryModuleName returns one of the following values:
  • 0 NO_ERROR
  • 6 ERROR_INVALID_HANDLE
  • 24 ERROR_BAD_LENGTH

Remarks

DosQueryModuleName returns the fully qualified drive, path, file name, and extension associated with the referenced module handle.

If the buffer is not large enough, an error is returned.

Example Code

This example attempts to obtain the handle of a dynamic link module named "DISPLAY.DLL," and then tests whether it is currently loaded or not.

#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;
}

Related Functions