Loads the specified resource into global memory.
Syntax
HGLOBAL LoadResource(
HMODULE hModule,
HRSRC hResInfo
);
Parameters
- hModule
-
[in] 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.
- hResInfo
-
[in] Handle to the resource to be loaded. This handle is returned by the FindResource or FindResourceEx function.
Return Value
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.
Remarks
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.
To use a resource immediately, an application should use the following resource-specific functions to find and load the resource in one call.
For example, an application can use the LoadIcon function to load an icon for display on the screen, followed by DestroyIcon when done.
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.
Example
For an example see Updating Resources.
Function Information
| Minimum DLL Version | kernel32.dll |
|---|
| Header | Declared in Winbase.h, include Windows.h |
|---|
| Import library | Kernel32.lib |
|---|
| Minimum operating systems |
Windows 95, Windows NT 3.1 |
|---|
| Unicode | Implemented as
Unicode version. |
|---|
See Also