Skip to content

Latest commit

 

History

History
204 lines (153 loc) · 6.5 KB

nf-libloaderapi-loadresource.md

File metadata and controls

204 lines (153 loc) · 6.5 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:libloaderapi.LoadResource
LoadResource function (libloaderapi.h)
Retrieves a handle that can be used to obtain a pointer to the first byte of the specified resource in memory.
LoadResource
LoadResource function [Menus and Other Resources]
_win32_LoadResource
_win32_loadresource_cpp
libloaderapi/LoadResource
menurc.loadresource
winui._win32_loadresource
menurc\loadresource.htm
menurc
VS|winui|~\winui\windowsuserinterface\resources\introductiontoresources\resourcereference\resourcefunctions\loadresource.htm
12/05/2018
LoadResource, LoadResource function [Menus and Other Resources], _win32_LoadResource, _win32_loadresource_cpp, libloaderapi/LoadResource, menurc.loadresource, winui._win32_loadresource
libloaderapi.h
Windows.h
Windows
Windows 2000 Professional [desktop apps only]
Windows 2000 Server [desktop apps only]
Kernel32.lib
Kernel32.dll
Windows
19H1
LoadResource
libloaderapi/LoadResource
c++
APIRef
kbSyntax
DllExport
Kernel32.dll
API-MS-Win-Core-LibraryLoader-l1-1-0.dll
KernelBase.dll
API-MS-Win-Core-LibraryLoader-l1-1-1.dll
API-MS-Win-Core-LibraryLoader-l1-2-0.dll
API-MS-Win-DownLevel-Kernel32-l1-1-0.dll
MinKernelBase.dll
API-MS-Win-Core-Libraryloader-l1-2-1.dll
API-MS-Win-Core-LibraryLoader-L1-2-2.dll
LoadResource

LoadResource function

-description

Retrieves a handle that can be used to obtain a pointer to the first byte of the specified resource in memory.

-parameters

-param hModule [in, optional]

Type: HMODULE

A 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.

-param hResInfo [in]

Type: HRSRC

A handle to the resource to be loaded. This handle is returned by the FindResource or FindResourceEx function.

-returns

Type: HGLOBAL

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 first byte of the resource data, call the LockResource function; to obtain the size of the resource, call SizeofResource.

GlobalSize returns 0 for a resource HGLOBAL. As a result, any APIs that depend on GlobalSize to determine the size of the HGLOBAL will not function correctly. For example, use SHCreateMemStream instead of CreateStreamOnHGlobal.

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.

Examples

For an example see Updating Resources.

-see-also

Conceptual

FindResource

FindResourceEx

LoadLibrary

LoadModule

LockResource

Other Resources

Reference

Resources