DosQueryResourceSize: Difference between revisions
m Ak120 moved page OS2 API:CPI:DosQueryResourceSize to DosQueryResourceSize |
No edit summary |
||
Line 1: | Line 1: | ||
==Syntax== | ==Syntax== | ||
DosQueryResourceSize (hmod, idt) | |||
==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 | |||
:#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. | ;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== | ==Return Code== | ||
ulrc (APIRET) - returns | ulrc (APIRET) - returns | ||
DosQueryResourceSize returns one of the following values: | DosQueryResourceSize returns one of the following values: | ||
*0 NO_ERROR | |||
*6 ERROR_INVALID_HANDLE | |||
*87 ERROR_INVALID_PARAMETER | |||
==Remarks== | ==Remarks== | ||
DosQueryResourceSize returns the size of the specified resource object. | DosQueryResourceSize returns the size of the specified resource object. | ||
Line 93: | Line 53: | ||
==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 90: | ||
return NO_ERROR; | return NO_ERROR; | ||
} | } | ||
</PRE> | |||
==Related Functions== | ==Related Functions== | ||
* [[ | *[[DosFreeResource]] | ||
* [[ | *[[DosGetResource]] | ||
* [[ | *[[DosLoadModule]] | ||
[[Category: | [[Category:Dos]] |
Revision as of 08:07, 10 January 2017
Syntax
DosQueryResourceSize (hmod, idt)
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
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
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; }