CreateIconFromResource function (winuser.h)
Creates an icon or cursor from resource bits describing the icon.
To specify a desired height or width, use the CreateIconFromResourceEx function.
Syntax
HICON CreateIconFromResource(
[in] PBYTE presbits,
[in] DWORD dwResSize,
[in] BOOL fIcon,
[in] DWORD dwVer
);
Parameters
[in] presbits
Type: PBYTE
The DWORD-aligned buffer pointer containing the icon or cursor resource bits. These bits are typically loaded by calls to the LookupIconIdFromDirectory, LookupIconIdFromDirectoryEx, and LoadResource functions.
See Cursor and Icon Resources for more info on icon and cursor resource format.
[in] dwResSize
Type: DWORD
The size, in bytes, of the set of bits pointed to by the presbits parameter.
[in] fIcon
Type: BOOL
Indicates whether an icon or a cursor is to be created. If this parameter is TRUE, an icon is to be created. If it is FALSE, a cursor is to be created.
The LOCALHEADER structure defines cursor hotspot and is the first data read from the cursor resource bits.
[in] dwVer
Type: DWORD
The version number of the icon or cursor format for the resource bits pointed to by the presbits parameter. The value must be greater than or equal to 0x00020000 and less than or equal to 0x00030000. This parameter is generally set to 0x00030000.
Return value
Type: HICON
If the function succeeds, the return value is a handle to the icon or cursor.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.
Remarks
The CreateIconFromResource, CreateIconFromResourceEx, CreateIconIndirect, GetIconInfo, LookupIconIdFromDirectory, and LookupIconIdFromDirectoryEx functions allow shell applications and icon browsers to examine and use resources throughout the system.
The CreateIconFromResource function calls CreateIconFromResourceEx passing LR_DEFAULTSIZE|LR_SHARED
as flags.
You should call DestroyIcon for icons or DestroyCursor for cursors created with CreateIconFromResource.
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 | winuser.h (include Windows.h) |
Library | User32.lib |
DLL | User32.dll |
See also
Conceptual
Reference