windows_programming_notes.nbk: Home | Index | Next Page: LockResource | Previous Page: LoadImage
Loads the specified resource into global memory.
HGLOBAL LoadResource( HMODULE hModule, HRSRC hResInfo );
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.
To use a resource immediately, an application should use the following resource-specific functions to find and load the resource in one call.
Function Action To remove resource FormatMessage Loads and formats a message-table entry No action needed LoadAccelerators Loads an accelerator table DestroyAcceleratorTable LoadBitmap Loads a bitmap resource DeleteObject LoadCursor Loads a cursor resource DestroyCursor LoadIcon Loads an icon resource DestroyIcon LoadMenu Loads a menu resource DestroyMenu LoadString Loads a string resource No action needed
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.
windows_programming_notes.nbk: Home | Index | Next Page: LockResource | Previous Page: LoadImage
Notebook exported on Monday, 7 July 2008, 18:56:50 PM Eastern Daylight Time