FreeResource function (libloaderapi.h)

Note

This function is obsolete and is only supported for backward compatibility with 16-bit Windows. For 32-bit Windows applications, it is not necessary to free the resources loaded using LoadResource. For modern versions of Windows this function always returns FALSE.

Decrements (decreases by one) the reference count of a loaded resource. When the reference count reaches zero, the memory occupied by the resource is freed.

Syntax

BOOL FreeResource(
  [in] HGLOBAL hResData
);

Parameters

[in] hResData

Type: HGLOBAL

A handle of the resource. It is assumed that hglbResource was created by LoadResource.

Return value

Type: BOOL

If the function succeeds, the return value is zero.

If the function fails, the return value is nonzero, which indicates that the resource has not been freed.

Remarks

For resources loaded with other functions, FreeResource has been replaced by the following functions:

Resource type FreeResource replacement
Accelerator DestroyAcceleratorTable
Bitmap DeleteObject
Cursor DestroyCursor
Icon DestroyIcon
Menu DestroyMenu
 

The reference count for a resource is incremented (increased by one) each time an application calls the LoadResource function for the resource.

The system automatically deletes these resources when the process that created them terminates. However, calling the appropriate function saves memory. For more information, see LoadResource.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header libloaderapi.h (include Windows.h)
Library Kernel32.lib
DLL Kernel32.dll

See also

DeleteObject

DestroyAcceleratorTable

DestroyCursor

DestroyIcon

DestroyMenu

LoadResource

Other Resources

Reference