Jump to content

DosQueryResourceSize: Difference between revisions

From EDM2
Ak120 (talk | contribs)
Ak120 (talk | contribs)
mNo edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Description==
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==
==Syntax==
<PRE>
DosQueryResourceSize (hmod, idt, idn, pulsize)


</PRE>
==Parameters==
==Parameters==
; hmod (HMODULE) - input : The handle of the module that has the required resource.
;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]].
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:
; idt (ULONG) - input : The type identifier of the resource.
:#RT_POINTER Mouse pointer shape
 
:#RT_BITMAP Bit map
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_MENU Menu template
 
:#RT_DIALOG Dialog template
    1 RT_POINTER  
:#RT_STRING String tables
    Mouse pointer shape
:#RT_FONTDIR Font directory
 
:#RT_FONT Font
    2 RT_BITMAP
:#RT_ACCELTABLE Accelerator tables
    Bit map
:#RT_RCDATA Binary data
 
:#RT_MESSAGE Error message tables
    3 RT_MENU
:#RT_DLGINCLUDE Dialog include file name
    Menu template
:#RT_VKEYTBL Key to vkey tables
 
:#RT_KEYTBL Key to UGL tables
    4 RT_DIALOG
:#RT_CHARTBL Glyph to character tables
    Dialog template
:#RT_DISPLAYINFO Screen display information
 
:#RT_FKASHORT Function key area short form
    5 RT_STRING
:#RT_FKALONG Function key area long form
    String tables
:#RT_HELPTABLE Help table for Help manager
 
:#RT_HELPSUBTABLE Help subtable for Help manager
    RT_FONTDIR
:#RT_FDDIR DBCS unique/font driver directory
    Font directory
:#RT_FD DBCS unique/font driver
 
    6 RT_FONT
    Font
 
    7 RT_ACCELTABLE
    Accelerator tables
 
    1 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.
;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.


Possible values are between 1 and 0xFFFE inclusive.
===Return Code===
 
;ulrc (APIRET) - returns:DosQueryResourceSize returns one of the following values:
; pulsize (PULONG) - output: A pointer to a ULONG in which the size, in bytes, of the resource is returned.
*0 NO_ERROR
==Return Code==
*6 ERROR_INVALID_HANDLE
ulrc (APIRET) - returns
*87 ERROR_INVALID_PARAMETER
 
DosQueryResourceSize returns one of the following values:
 
*0         NO_ERROR  
* 6         ERROR_INVALID_HANDLE  
* 87       ERROR_INVALID_PARAMETER
*
==Remarks==
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.


==Example Code==
==Example Code==
This example loads the dynamic link module "DISPLAY.DLL," and queries the size of the font directory id=1 resource.
This example loads the dynamic link module "DISPLAY.DLL", and queries the size of the font directory id=1 resource.
 
<PRE>
<PRE>
#define INCL_DOSRESOURCES    /* Resource types */
#define INCL_DOSRESOURCES    /* Resource types */
Line 131: Line 85:
return NO_ERROR;
return NO_ERROR;
}
}
</PRE>


</PRE>
==Related Functions==
==Related Functions==
* [[OS2 API:CPI:DosFreeResource|DosFreeResource]]
*[[DosFreeResource]]
* [[OS2 API:CPI:DosGetResource|]DosGetResource]
*[[DosGetResource]]
* [[OS2 API:CPI:DosLoadModule |DosLoadModule]]
*[[DosLoadModule]]
 


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

Latest revision as of 18:40, 29 August 2021

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:
  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
  • 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.

#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