CopyIcon function (winuser.h)

Copies the specified icon from another module to the current module.

Syntax

HICON CopyIcon(
  [in] HICON hIcon
);

Parameters

[in] hIcon

Type: HICON

A handle to the icon to be copied.

Return value

Type: HICON

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

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

Remarks

The CopyIcon function enables an application or DLL to get its own handle to an icon owned by another module. If the other module is freed, the application icon will still be able to use the icon.

Before closing, an application must call the DestroyIcon function to free any system resources associated with the icon.

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
API set ext-ms-win-ntuser-gui-l1-3-0 (introduced in Windows 10, version 10.0.10240)

See also

Conceptual

CopyCursor

DestroyIcon

DrawIcon

DrawIconEx

Icons

Reference