DosQueryResourceSize

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.

Syntax
DosQueryResourceSize (hmod, idt, idn, pulsize)

Parameters

 * 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:
 * RT_POINTER Mouse pointer shape
 * RT_BITMAP Bit map
 * RT_MENU Menu template
 * RT_DIALOG Dialog template
 * RT_STRING String tables
 * RT_FONTDIR Font directory
 * RT_FONT Font
 * RT_ACCELTABLE Accelerator tables
 * RT_RCDATA Binary data
 * RT_MESSAGE Error message tables
 * RT_DLGINCLUDE Dialog include file name
 * RT_VKEYTBL Key to vkey tables
 * RT_KEYTBL Key to UGL tables
 * RT_CHARTBL Glyph to character tables
 * RT_DISPLAYINFO Screen display information
 * RT_FKASHORT Function key area short form
 * RT_FKALONG Function key area long form
 * RT_HELPTABLE Help table for Help manager
 * RT_HELPSUBTABLE Help subtable for Help manager
 * RT_FDDIR DBCS unique/font driver directory
 * 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
 * 6 ERROR_INVALID_HANDLE
 * 87 ERROR_INVALID_PARAMETER

Example Code
This example loads the dynamic link module "DISPLAY.DLL", and queries the size of the font directory id=1 resource. 
 * 1) define INCL_DOSRESOURCES    /* Resource types */
 * 2) define INCL_DOSMODULEMGR    /* Module Manager values */
 * 3) define INCL_DOSERRORS       /* DOS error values */
 * 4) include 
 * 5) include 

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

 * DosFreeResource
 * DosGetResource
 * DosLoadModule