LoadResource

This function loads the specified resource into global memory.

HGLOBAL LoadResource( 
HMODULE hModule, 
HRSRC hResInfo ); 

Parameters

  • hModule
    Handle to the module whose executable file contains the resource. If hModule is NULL, the system loads the resource from the module that was used to create the current process. In Windows CE versions 1.0 and 1.01, setting this parameter to NULL is not supported.
  • hResInfo
    Handle to the resource to be loaded. This handle must be created by using the FindResource function.

Return Values

A handle to the data associated with the resource indicates success. NULL indicates failure. To get extended error information, call GetLastError.

Remarks

The return type of LoadResource is HGLOBAL for backward compatibility, not because the function returns a handle to a global memory block.

When you are finished using a bitmap, cursor, icon, or menu, you can release its associated memory by calling one of the functions in the following table.

Resource Release function
Bitmap DeleteObject
Cursor DestroyCursor
Icon DestroyIcon
Menu DestroyMenu

The system automatically deletes these resources when the process that loaded them terminates, however, calling the appropriate function saves memory and decreases the size of the process's working set.

Accelerator tables are an exception. They remain in memory until the process terminates.

Requirements

Runs on Versions Defined in Include Link to
Windows CE OS 1.0 and later Winbase.h   Coredll.lib, Nk.lib

Note   This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.

See Also

DeleteObject, DestroyCursor, DestroyIcon, DestroyMenu, FindResource, GetLastError, LoadLibrary

 Last updated on Tuesday, July 13, 2004

© 1992-2000 Microsoft Corporation. All rights reserved.