DestroyIcon

The DestroyIcon function destroys an icon and frees any memory the icon occupied.

BOOL DestroyIcon(
  HICON hIcon   // handle to icon to destroy
);
 

Parameters

hIcon
Handle to the icon to be destroyed. The icon must not be in use.

Return Values

If the function succeeds, the return value is nonzero.

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

Remarks

It is only necessary to call DestroyIcon for icons and cursors created with the CreateIconIndirect function. Do not use this function to destroy a shared icon. A shared icon is valid as long as the module from which it was loaded remains in memory. The following functions obtain a shared icon:

Windows CE: The DestroyIcon function may be called on the icon handle returned from CreateIconIndirect, ExtractIconEx, LoadImage or LoadIcon. The icon handle is invalid after calling DestroyIcon.

QuickInfo

  Windows NT: Requires version 3.1 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Requires version 1.0 or later.
  Header: Declared in winuser.h.
  Import Library: Use user32.lib.

See Also

Icons Overview, Icon Functions, CreateIconIndirect