dos12.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
DosGetResource2 (1.2)
                                                      Up Next Previous
────────────────────────────────────────────────────────────────────────────
 
#define INCL_DOSRESOURCES
 
USHORT DosGetResource2(hmod, idType, idName, ppData)
HMODULE hmod;          /* module handle                            */
USHORT idType;         /* resource-type identifier                 */
USHORT idName;         /* resource-name identifier                 */
PVOID FAR * ppData;    /* pointer to variable for resource address */
 
The DosGetResource2 function retrieves a pointer to a resource.
 
Parameter  Description
────────────────────────────────────────────────────────────────────────────
 
hmod       Identifies the module that contains the resource. This parameter
           can be the module handle returned by the DosLoadModule function
           or NULL for the application's module.
 
idType     Specifies the type of resource to retrieve. For a list of
           predefined types, see the Resource types topic.
 
idName     Specifies the name of the resource to retrieve.
 
ppData     Points to the variable that receives the pointer to the
           resource.
 
Return Value
 
The return value is zero if the function is successful. Otherwise, it is an
error value, which may be one of the following:
 
     ERROR_INVALID_PARAMETER
     ERROR_INVALID_MODULETYPE
 
Comments
 
The DosGetResource2 function allocates a segment, copies the resource into
the segment, and returns a pointer to the resource. A process can use this
pointer to access the resource directly. For compatibility with future
versions of MS OS/2, this function should be used instead of the
DosGetResource function, which returns a selector instead of a pointer.
 
Example
 
This example calls DosGetResource2 to retrieve a resource from the
application's module, and then calls DosFreeResource to free the memory used
by the resource:
 
PBYTE pResource;
 
if (!DosGetResource2(
        (HMODULE) NULL,      /* loads from application's module */
        RT_MENU,             /* gets menu resource              */
        IDM_MENU,            /* ID of menu to get               */
        &pResource)) {       /* pointer address                 */
    .
    .
    .
    DosFreeResource(pResource);  /* frees resource              */
 
See Also
 
DosFreeResource, DosGetResource, DosLoadModule, Resource Compiler