private static IntPtr GetIcon(ShellApi.StockIconIdentifier identifier, ShellApi.StockIconOptions flags) { var info = new ShellApi.StockIconInfo { StuctureSize = (UInt32)Marshal.SizeOf(typeof(ShellApi.StockIconInfo)) }; var hResult = Shell32.SHGetStockIconInfo(identifier, flags, ref info); if (hResult < 0) { throw new COMException("SHGetStockIconInfo execution failure", hResult); } return(info.Handle); }
public StockIcons this[ShellApi.StockIconOptions flags] { get { return(new StockIcons(flags)); } }
private StockIcons(ShellApi.StockIconOptions flags) { _flags = flags; }
private static ImageSource MakeImage(ShellApi.StockIconIdentifier identifier, ShellApi.StockIconOptions flags) { var iconHandle = GetIcon(identifier, flags); ImageSource imageSource; try { imageSource = Imaging.CreateBitmapSourceFromHIcon(iconHandle, Int32Rect.Empty, null); } finally { User32.DestroyIcon(iconHandle); } return(imageSource); }
internal static extern int SHGetStockIconInfo(ShellApi.StockIconIdentifier identifier, ShellApi.StockIconOptions flags, ref ShellApi.StockIconInfo info);