Partager via


LoadResource (Compact 2013)

3/28/2014

This function returns a handle to a specified resource located in a dynamic-link library (DLL) or executable.

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.
  • hResInfo
    Handle to the resource to be loaded. This handle must be created by using the FindResource function.

Return Value

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. Always use LockResource to convert the handle returned by LoadResource into a pointer.

The resources in an application, whether from an executable or a DLL, are always mapped to the address space of a process. LoadResource simply retrieves the address of the resource that is already in memory. LoadResource does not allocate any additional memory. The pointer returned by LockResource identifies the address of the block of memory, in the executable or in the DLL, containing the specified resource. The system automatically deletes these resources when the process that loaded them terminates, or when FreeLibrary is used to unload a DLL that was loaded with LoadLibrary.

Requirements

Header

winbase.h

Library

coredll.lib,
Nk.lib

See Also

Reference

Resources Functions
FindResource
LockResource

Other Resources

LoadLibrary
FreeLibrary