Click to Rate and Give Feedback
MSDN
MSDN Library
User Interface
Resources
Icons
Icon Reference
Functions
 CreateIconFromResource Function
CreateIconFromResource Function

The CreateIconFromResource function 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(      
    PBYTE presbits,     DWORD dwResSize,     BOOL fIcon,     DWORD dwVer );

Parameters

presbits
[in] Pointer to a buffer containing the icon or cursor resource bits. These bits are typically loaded by calls to the LookupIconIdFromDirectory, LookupIconIdFromDirectoryEx, and LoadResource functions.
dwResSize
[in] Specifies the size, in bytes, of the set of bits pointed to by the presbits parameter.
fIcon
[in] Specifies 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.
dwVer
[in] Specifies the version number of the icon or cursor format for the resource bits pointed to by the presbits parameter. This parameter can be 0x00030000.

Return Value

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.

When you are finished using the icon, destroy it using the DestroyIcon function.

Function Information

Minimum DLL Versionuser32.dll
HeaderDeclared in Winuser.h, include Windows.h
Import libraryUser32.lib
Minimum operating systems Windows 95, Windows NT 3.1
UnicodeImplemented as Unicode version.

See Also

Icons Overview, CreateIconFromResourceEx, CreateIconIndirect, GetIconInfo, LoadResource, LookupIconIdFromDirectory, LookupIconIdFromDirectoryEx
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content      
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker