From EDM2
Jump to: navigation, search

DosQueryResourceSize returns the size of the specified resource object.

Resource objects are read-only data objects that can be accessed dynamically at run time. The access key is two numbers. The first number is a type ID; the second, a name ID. These are similar to the file-extension and file-name portions of a file name.

Resource objects are placed into an executable file by the Resource Compiler (RC.EXE).

This function obtains the size of resources loaded from 16-bit executable files or dynamic link libraries (DLLs), since the size is not explicitly stored in most resources.


DosQueryResourceSize (hmod, idt, idn, pulsize)


hmod (HMODULE) - input 
The handle of the module that has the required resource.
A value of zero means to get the size from the current process. A value other than zero is a module handle that was returned by DosLoadModule.
idt (ULONG) - input 
The type identifier of the resource.
Possible values are between 1 and 0xFFFE inclusive. Values from 1 to 255 are reserved for predefinition. Values from 256 and on can be type defined for the resource. The fist 21 values are predefined as follows:
  1. RT_POINTER Mouse pointer shape
  2. RT_BITMAP Bit map
  3. RT_MENU Menu template
  4. RT_DIALOG Dialog template
  5. RT_STRING String tables
  6. RT_FONTDIR Font directory
  7. RT_FONT Font
  8. RT_ACCELTABLE Accelerator tables
  9. RT_RCDATA Binary data
  10. RT_MESSAGE Error message tables
  11. RT_DLGINCLUDE Dialog include file name
  12. RT_VKEYTBL Key to vkey tables
  13. RT_KEYTBL Key to UGL tables
  14. RT_CHARTBL Glyph to character tables
  15. RT_DISPLAYINFO Screen display information
  16. RT_FKASHORT Function key area short form
  17. RT_FKALONG Function key area long form
  18. RT_HELPTABLE Help table for Help manager
  19. RT_HELPSUBTABLE Help subtable for Help manager
  20. RT_FDDIR DBCS unique/font driver directory
  21. RT_FD DBCS unique/font driver
idn (ULONG) - input 
The name identifier of the resource.
Possible values are between 1 and 0xFFFE inclusive.
pulsize (PULONG) - output
A pointer to a ULONG in which the size, in bytes, of the resource is returned.

Return Code

ulrc (APIRET) - returns

DosQueryResourceSize returns one of the following values:

  • 0 NO_ERROR

Example Code

This example loads the dynamic link module "DISPLAY.DLL", and queries the size of the font directory id=1 resource.

#define INCL_DOSRESOURCES     /* Resource types */
#define INCL_DOSMODULEMGR     /* Module Manager values */
#define INCL_DOSERRORS        /* DOS error values */
#include <os2.h>
#include <stdio.h>

int main(VOID) {
UCHAR     LoadError[256] = "";            /* Area for Load failure information */
PSZ       ModuleName = "C:\\OS2\\DLL\\PMWP.DLL";  /* DLL with resources */
HMODULE   ModHandle  = NULLHANDLE;        /* Handle for module */
ULONG     Size       = 0;                 /* Resource size */
APIRET    rc         = NO_ERROR;          /* API return code */

 rc = DosLoadModule(LoadError,               /* Failure information buffer */
                    sizeof(LoadError),       /* Size of buffer             */
                    ModuleName,              /* Module to load             */
                    &ModHandle);             /* Module handle returned     */
 if (rc != NO_ERROR) {
    printf("DosLoadModule error: return code = %u\n", rc);
    return 1;

 rc = DosQueryResourceSize(ModHandle,     /* Handle for DLL containing resources */
                           RT_POINTER,    /* Ask for  Pointer                    */
                           1L,            /*          with an ID of 1            */
                           &Size);        /* The resource size is returned.      */

 if (rc != NO_ERROR) {
    printf("DosGetResource error: return code = %u\n", rc);
    return 1;
 } else {
    printf("Resource is %u bytes in size.\n", Size);
 } /* endif */

return NO_ERROR;

Related Functions