This function loads the specified resource into global memory.
At a Glance
Header file: | Winbase.h |
Windows CE versions: | 1.0 and later |
Syntax
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.
See Also