internal static BitmapSource GetImage(NativeStockIcon icon, NativeStockIconOptions options) { options |= NativeStockIconOptions.Handle; StockIconInfo info = new StockIconInfo(); info.StructureSize = (uint) Marshal.SizeOf (typeof (StockIconInfo)); int hresult = SHGetStockIconInfo (icon, options, ref info); if (hresult < 0) throw new COMException ("SHGetStockIconInfo failed", hresult); BitmapSource bitmap; try { bitmap = Imaging.CreateBitmapSourceFromHIcon (info.Handle, Int32Rect.Empty, null); } finally { DestroyIcon (info.Handle); } return bitmap; }
internal static extern int SHGetStockIconInfo(StockIconIdentifier identifier, StockIconOptions flags, ref StockIconInfo info);
internal static IntPtr GetIcon(StockIconIdentifier identifier, StockIconOptions flags) { StockIconInfo info = new StockIconInfo(); info.StuctureSize = (UInt32)Marshal.SizeOf(typeof(StockIconInfo)); int hResult = SHGetStockIconInfo(identifier, flags, ref info); if (hResult < 0) throw new COMException("SHGetStockIconInfo execution failure", hResult); return info.Handle; }
static extern int SHGetStockIconInfo(NativeStockIcon icon, NativeStockIconOptions options, ref StockIconInfo info);
public static string GetIcon(int identifier) { StockIconInfo info = new StockIconInfo(); info.StuctureSize = (UInt32)System.Runtime.InteropServices.Marshal.SizeOf(typeof(StockIconInfo)); int hResult = SHGetStockIconInfo(identifier, 0, ref info); if (hResult != 0) throw new System.ComponentModel.Win32Exception("SHGetStockIconInfo execution failure " + hResult.ToString()); return info.Path + "," + info.Identifier; }
private static extern int SHGetStockIconInfo( int identifier, int flags, ref StockIconInfo info);
internal static extern HResult SHGetStockIconInfo( StockIconIdentifier identifier, StockIconOptions flags, ref StockIconInfo info);
private static extern IntPtr SHGetStockIconInfo( StockIconId siid, // 取得するアイコンの IDを指定する StockIconId enum 型 StockIconFlags uFlags, // 取得するアイコンの種類を指定する StockIconFlags enum 型 ref StockIconInfo psii //(戻り値)StockIconInfo 型 );
internal static extern int SHGetStockIconInfo(uint siid, uint uFlags, ref StockIconInfo psii);
public static extern HResult SHGetStockIconInfo( StockIconIdentifier identifier, StockIconOptions flags, ref StockIconInfo info);