LoadIcon

2.x

  HICON LoadIcon(hinst, pszIcon)    
  HINSTANCE hinst; /* handle of application instance */
  LPCSTR pszIcon; /* icon-name string or icon resource identifier */

The LoadIcon function loads the specified icon resource from the executable file associated with the given application instance.

Parameters

hinst

Identifies an instance of the module whose executable file contains the icon to be loaded. This parameter must be NULL when a system icon is being loaded.

pszIcon

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

Return Value

The return value is the handle of the newly loaded icon if the function is successful. Otherwise, it is NULL.

Comments

This function loads the icon resource only if it has not been loaded; otherwise, it retrieves a handle of the existing resource.

An application can use the LoadIcon function to access the predefined icons used by Windows. To do this, the application must set the hinst parameter to NULL and the pszIcon parameter to one of the following values:

Value Meaning

IDI_APPLICATION Default application icon.
IDI_ASTERISK Asterisk (used in informative messages).
IDI_EXCLAMATION Exclamation point (used in warning messages).
IDI_HAND Hand-shaped icon (used in serious warning messages).
IDI_QUESTION Question mark (used in prompting messages).

It is not necessary to destroy these system icons. An application should use the DestroyIcon function to destroy any private icons it loads.

The following shows all of the system icons.

See Also

DestroyIcon, DrawIcon