Jump to content

DosGetResource (OS/2 1.x): Difference between revisions

From EDM2
Created page with "==Description== This call returns the segment selector of the specified resource segment. ==Syntax== <PRE> DosGetResource (ModHandle, TypeID, NameID, Selector) </PRE>..."
 
Ak120 (talk | contribs)
mNo edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==Description==
This call returns the segment selector of the specified resource segment.
This call returns the segment selector of the specified resource segment.  


==Syntax==
==Syntax==
<PRE>
  DosGetResource (ModHandle, TypeID, NameID, Selector)
  DosGetResource


    (ModHandle, TypeID, NameID, Selector)
</PRE>
==Parameters==
==Parameters==
; ModHandle (HMODULE) - input : The location of the resource segment.
;ModHandle ([[HMODULE]]) - input: The location of the resource segment.
 
::0 - The executable file of the current process.
'''Value        Definition'''
::<> 0 - A handle to a dynamic link module returned by DosLoadModule.
0       The executable file of the current process.  
;TypeID (USHORT) - input : A 16 bit resource type ID (see Remarks).
<> 0       A handle to a dynamic link module returned by DosLoadModule.  
;NameID (USHORT) - input : A 16 bit resource name ID (see Remarks).
 
;Selector (PSEL) - output : The address of a word where the resource segment selector is returned.
; TypeID (USHORT) - input : A 16 bit resource type ID (see Remarks).  
 
; NameID (USHORT) - input : A 16 bit resource name ID (see Remarks).  
 
; Selector (PSEL) - output : The address of a word where the resource segment selector is returned.


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


==Remarks==
==Remarks==
Line 34: Line 22:
The advantage of resource segments is that they 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 resource segments is that they can be bundled into an application's executable file, so a single file contains all of the code and data for an application.


It is recommended that resource segments obtained through DosGetResource only be freed using DosFreeSeg.
It is recommended that resource segments obtained through DosGetResource only be freed using [[DosFreeSeg]].


OS/2 Version 1.2 added two new functions, DosGetResource2 and DosFreeResource, to load and free an application specific resource. DosGetResource2 returns a far pointer to a resource rather than the selector returned via DosGetResource. It is recommended that applications targeted for OS/2 1.2 use DosGetResource2 and DosFreeResource. Applications that wish to execute on OS/2 1.1 and 1.2 should use the OS/2 run-time dynamic link capabilities, DosLoadModule and DosGetProcAddr, to get the address of DosGetResource2 and DosFreeResource when executing on OS/2 1.2. If the DosGetProcAddr call to obtain the address of DosGetResource2 and DosFreeResource fails, the application can call DosGetResource and DosFreeSeg. Applications that use DosGetResource2 and DosFreeResource allow OS/2 to optimize memory allocation associated with the applications resource.  
OS/2 Version 1.2 added two new functions, [[DosGetResource2]] and [[DosFreeResource (OS/2 1.x)|DosFreeResource]], to load and free an application specific resource. DosGetResource2 returns a far pointer to a resource rather than the selector returned via DosGetResource. It is recommended that applications targeted for OS/2 1.2 use ''DosGetResource2'' and ''DosFreeResource''. Applications that wish to execute on OS/2 1.1 and 1.2 should use the OS/2 run-time dynamic link capabilities, DosLoadModule and DosGetProcAddr, to get the address of DosGetResource2 and DosFreeResource when executing on OS/2 1.2. If the DosGetProcAddr call to obtain the address of DosGetResource2 and DosFreeResource fails, the application can call DosGetResource and DosFreeSeg. Applications that use DosGetResource2 and DosFreeResource allow OS/2 to optimize memory allocation associated with the applications resource.


==Example Code==
==Bindings==
===C Binding===
===C===
<PRE>
<PRE>
#define INCL_DOSRESOURCES
#define INCL_DOSRESOURCES
Line 45: Line 33:
USHORT  rc = DosGetResource(ModHandle, TypeID, NameID, Selector);
USHORT  rc = DosGetResource(ModHandle, TypeID, NameID, Selector);


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 */
PSEL             Selector;      /* where to return selector */
PSEL   Selector;      /* where to return selector */


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


===MASM Binding===
===MASM===
<PRE>
<PRE>
EXTRN  DosGetResource:FAR
EXTRN  DosGetResource:FAR
INCL_DOSRESOURCES  EQU 1
INCL_DOSRESOURCES  EQU 1


PUSH  WORD    ModHandle     ;Module handle to get resource from
PUSH  WORD    ModHandle   ;Module handle to get resource from
PUSH  WORD    TypeID       ;16 bit resource type ID
PUSH  WORD    TypeID       ;16 bit resource type ID
PUSH  WORD    NameID       ;16 bit resource name ID
PUSH  WORD    NameID       ;16 bit resource name ID
PUSH@  WORD    Selector     ;Resource selector (returned)
PUSH@  WORD    Selector     ;Resource selector (returned)
CALL  DosGetResource
CALL  DosGetResource


Returns WORD
Returns WORD
</PRE>
</PRE>
==Related Functions==
*


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

Latest revision as of 01:25, 26 January 2020

This call returns the segment selector of the specified resource segment.

Syntax

DosGetResource (ModHandle, TypeID, NameID, Selector)

Parameters

ModHandle (HMODULE) - input
The location of the resource segment.
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).
Selector (PSEL) - output
The address of a word where the resource segment selector is returned.

Return Code

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

Remarks

Resource segments are read-only data segments 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 resource segments is that they can be bundled into an application's executable file, so a single file contains all of the code and data for an application.

It is recommended that resource segments obtained through DosGetResource only be freed using DosFreeSeg.

OS/2 Version 1.2 added two new functions, DosGetResource2 and DosFreeResource, to load and free an application specific resource. DosGetResource2 returns a far pointer to a resource rather than the selector returned via DosGetResource. It is recommended that applications targeted for OS/2 1.2 use DosGetResource2 and DosFreeResource. Applications that wish to execute on OS/2 1.1 and 1.2 should use the OS/2 run-time dynamic link capabilities, DosLoadModule and DosGetProcAddr, to get the address of DosGetResource2 and DosFreeResource when executing on OS/2 1.2. If the DosGetProcAddr call to obtain the address of DosGetResource2 and DosFreeResource fails, the application can call DosGetResource and DosFreeSeg. Applications that use DosGetResource2 and DosFreeResource allow OS/2 to optimize memory allocation associated with the applications resource.

Bindings

C

#define INCL_DOSRESOURCES

USHORT  rc = DosGetResource(ModHandle, TypeID, NameID, Selector);

HMODULE ModHandle;     /* Module handle to get resource from */
USHORT  TypeID;        /* 16 bit resource type ID */
USHORT  NameID;        /* 16 bit resource name ID */
PSEL    Selector;      /* where to return selector */

USHORT  rc;            /* return code */

MASM

EXTRN  DosGetResource:FAR
INCL_DOSRESOURCES   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@  WORD    Selector     ;Resource selector (returned)
CALL   DosGetResource

Returns WORD