Beispiel #1
0
        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);
        }
Beispiel #2
0
        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;
        }
Beispiel #3
0
        static extern int SHGetStockIconInfo(NativeStockIcon icon, NativeStockIconOptions options,
		                                               ref StockIconInfo info);
Beispiel #4
0
 static extern int SHGetStockIconInfo(NativeStockIcon icon, NativeStockIconOptions options,
                                      ref StockIconInfo info);