Jump to content

DosGetResource2: Difference between revisions

From EDM2
Ak120 (talk | contribs)
mNo edit summary
Ak120 (talk | contribs)
mNo edit summary
 
Line 1: Line 1:
{{Legacy
|RepFunc=[[DosGetResource]]
|Remarks=This page list the older version of the function for reference.
}}
This call returns the far address of the specified resource.
This call returns the far address of the specified resource.


Line 9: Line 5:


==Parameters==
==Parameters==
; ModHandle (HMODULE) - input : The location of the resource.
;ModHandle ([[HMODULE]]) - input : The location of the resource.
'''Value        Definition'''
::0 - The executable file of the current process.
0           The executable file of the current process.
::<> 0 - A handle to a dynamic link module returned by DosLoadModule.
<> 0       A handle to a dynamic link module returned by DosLoadModule.
;TypeID (USHORT) - input : A 16 bit resource type ID (see Remarks).
; TypeID (USHORT) - input : A 16 bit resource type ID (see Remarks).
;NameID (USHORT) - input : A 16 bit resource name ID (see Remarks).
; NameID (USHORT) - input : A 16 bit resource name ID (see Remarks).
;ResAddr (PULONG) - output : Address of the resource address.
; ResAddr (PULONG) - output : Address of the resource address.  


==Return Code==
==Return Code==
;rc (USHORT) - return:Return code descriptions are:
;rc (USHORT) - return:Return code descriptions are:
* 0 NO_ERROR
*0 NO_ERROR
* 6 ERROR_INVALID_HANDLE
*6 ERROR_INVALID_HANDLE


==Remarks==
==Remarks==
Line 27: Line 22:
The advantage of a resource is that it can be bundled into an application's executable file, so a single file contains all of the code and data for an application.
The advantage of a resource is that it can be bundled into an application's executable file, so a single file contains all of the code and data for an application.


Resource segments obtained through DosGetResource2 should only be freed using DosFreeResource.
Resource segments obtained through DosGetResource2 should only be freed using [[DosFreeResource]].


==Example Code==
==Bindings==
===C Binding===
===C===
<PRE>
<PRE>
#define INCL_DOSRESOURCES2
#define INCL_DOSRESOURCES2
Line 36: Line 31:
USHORT  rc = DosGetResource2(ModHandle, TypeID, NameID, ResAddr);
USHORT  rc = DosGetResource2(ModHandle, TypeID, NameID, ResAddr);


HMODULE         ModHandle;    /* Module handle to get resource from */
HMODULE ModHandle;    /* Module handle to get resource from */
USHORT           TypeID;        /* 16 bit resource type ID */
USHORT TypeID;        /* 16 bit resource type ID */
USHORT           NameID;        /* 16 bit resource name ID */
USHORT NameID;        /* 16 bit resource name ID */
PULONG           ResAddr;      /* where to return resource address */
PULONG ResAddr;      /* where to return resource address */


USHORT           rc;            /* return code */
USHORT rc;            /* return code */
</PRE>
</PRE>


===MASM Binding===
===MASM===
<PRE>
<PRE>
EXTRN  DosGetResource2:FAR
EXTRN  DosGetResource2:FAR
Line 57: Line 52:
Returns WORD
Returns WORD
</PRE>
</PRE>
==Related Functions==
*[[DosFreeResource]]


[[Category:Dos]]
[[Category:Dos16]]

Latest revision as of 01:28, 26 January 2020

This call returns the far address of the specified resource.

Syntax

DosGetResource2 (ModHandle, TypeID, NameID, ResAddr)

Parameters

ModHandle (HMODULE) - input
The location of the resource.
0 - The executable file of the current process.
<> 0 - A handle to a dynamic link module returned by DosLoadModule.
TypeID (USHORT) - input
A 16 bit resource type ID (see Remarks).
NameID (USHORT) - input
A 16 bit resource name ID (see Remarks).
ResAddr (PULONG) - output
Address of the resource address.

Return Code

rc (USHORT) - return
Return code descriptions are:
  • 0 NO_ERROR
  • 6 ERROR_INVALID_HANDLE

Remarks

A resource is read-only data generated by the Resource Compiler that can be accessed dynamically at run time. The access key consists of two 16-bit numbers, the first of which is a type ID and the second, a name ID. These numbers are similar in concept to the file extension and file name portions of a file name.

The advantage of a resource is that it can be bundled into an application's executable file, so a single file contains all of the code and data for an application.

Resource segments obtained through DosGetResource2 should only be freed using DosFreeResource.

Bindings

C

#define INCL_DOSRESOURCES2

USHORT  rc = DosGetResource2(ModHandle, TypeID, NameID, ResAddr);

HMODULE ModHandle;     /* Module handle to get resource from */
USHORT  TypeID;        /* 16 bit resource type ID */
USHORT  NameID;        /* 16 bit resource name ID */
PULONG  ResAddr;       /* where to return resource address */

USHORT  rc;            /* return code */

MASM

EXTRN  DosGetResource2:FAR
INCL_DOSRESOURCES2  EQU 1

PUSH   WORD    ModHandle     ;Module handle to get resource from
PUSH   WORD    TypeID        ;16 bit resource type ID
PUSH   WORD    NameID        ;16 bit resource name ID
PUSH@  DWORD   ResAddr       ;Resource address (returned)
CALL   DosGetResource2

Returns WORD