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

The LoadIcon function loads the specified icon resource from the executable (.exe) file associated with an application instance.

Note  This function hase been superseded by the LoadImage function.

Syntax

HICON LoadIcon(      
    HINSTANCE hInstance,     LPCTSTR lpIconName );

Parameters

hInstance
[in] Handle to an instance of the module whose executable file contains the icon to be loaded. This parameter must be NULL when a standard icon is being loaded.
lpIconName
[in] 

Pointer to a null-terminated string that contains the name of the icon resource to be loaded. Alternatively, this parameter can contain the resource identifier in the low-order word and zero in the high-order word. Use the MAKEINTRESOURCE macro to create this value.

To use one of the predefined icons, set the hInstance parameter to NULL and the lpIconName parameter to one of the following values.

IDI_APPLICATION
Default application icon.
IDI_ASTERISK
Same as IDI_INFORMATION.
IDI_ERROR
Hand-shaped icon.
IDI_EXCLAMATION
Same as IDI_WARNING.
IDI_HAND
Same as IDI_ERROR.
IDI_INFORMATION
Asterisk icon.
IDI_QUESTION
Question mark icon.
IDI_WARNING
Exclamation point icon.
IDI_WINLOGO
Windows logo icon. Windows XP: Default application icon.
IDI_SHIELD
Security Shield icon.

Return Value

If the function succeeds, the return value is a handle to the newly loaded icon.

If the function fails, the return value is NULL. To get extended error information, call GetLastError.

Remarks

LoadIcon loads the icon resource only if it has not been loaded; otherwise, it retrieves a handle to the existing resource. The function searches the icon resource for the icon most appropriate for the current display. The icon resource can be a color or monochrome bitmap.

LoadIcon can only load an icon whose size conforms to the SM_CXICON and SM_CYICON system metric values. Use the LoadImage function to load icons of other sizes.

Windows 95/98/Me: LoadIconW is supported by the Microsoft Layer for Unicode (MSLU). To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows 95/98/Me Systems.

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 ANSI and Unicode versions.

See Also

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2010 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker