The LoadResource function loads the specified resource into global memory.
HGLOBAL LoadResource(
HMODULE hModule, // resource-module handle
HRSRC hResInfo // resource handle
);
If the function succeeds, the return value is a handle to the data associated with the resource.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.
The return type of LoadResource is HGLOBAL for backward compatibility, not because the function returns a handle to a global memory block. Do not pass this handle to the GlobalLock or GlobalFree function. To obtain a pointer to the resource data, call the LockResource function.
When you are finished using an accelerator table, bitmap, cursor, icon, or menu, you can release its associated memory by calling one of the functions in the following table.
Resource | Release function |
---|---|
Accelerator table | DestroyAcceleratorTable |
Bitmap | DeleteObject |
Cursor | DestroyCursor |
Icon | DestroyIcon |
Menu | DestroyMenu |
The system automatically deletes these resources when the process that created them terminates, however, calling the appropriate function saves memory and decreases the size of the process's working set.
Windows CE: The hModule parameter must be non-NULL.
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winbase.h.
Import Library: Use kernel32.lib.
Resources Overview, Resource Functions, FindResource, FindResourceEx, LoadLibrary, LoadModule, LockResource