SHGetStockIconInfo (shell32)
Last changed: -88.235.99.88

.
Summary
Retrieves information about a stock icon

C# Signature:

[DllImport("Shell32.dll", SetLastError = false)]
public static extern Int32 SHGetStockIconInfo(SHSTOCKICONID siid, SHGSI uFlags, ref SHSTOCKICONINFO psii);

VB Signature:

Declare Function SHGetStockIconInfo Lib "Shell32.dll" (TODO) As TODO

User-Defined Types:

See SHSTOCKICONID, SHGSI and SHSTOCKICONINFO.

Alternative Managed API:

System.Drawing.SystemIcons, although note that not all icons are included and at least the Shield icon is incorrect on Win 7 / Win 2008.

Notes:

SHGetStockIconInfo is supported on Windows Vista / 2008 or later.

Tips & Tricks:

Please add some!

Sample Code:

SHSTOCKICONINFO sii = new SHSTOCKICONINFO();
sii.cbSize = (UInt32) Marshal.SizeOf(typeof(SHSTOCKICONINFO));

Marshal.ThrowExceptionForHR(SHGetStockIconInfo(SHSTOCKICONID.SIID_SHIELD,
     SHGSI.SHGSI_ICON | SHGSI.SHGSI_SMALLICON,
     ref sii));

// do something with sii.hIcon

DestroyIcon(sii.hIcon);

Documentation