private static BitmapSource CreateUacShield() { if (Environment.OSVersion.Version.Major >= 6) { var sii = new NativeMethods.SHSTOCKICONINFO(); sii.cbSize = (UInt32)Marshal.SizeOf(typeof(NativeMethods.SHSTOCKICONINFO)); Marshal.ThrowExceptionForHR(NativeMethods.SHGetStockIconInfo(77, 0x0101, ref sii)); try { return(Imaging.CreateBitmapSourceFromHIcon( sii.hIcon, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions())); } finally { NativeMethods.DestroyIcon(sii.hIcon); } } else { return(Imaging.CreateBitmapSourceFromHIcon( SystemIcons.Shield.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions())); } }
private static BitmapSource CreateUacShield() { if (Environment.OSVersion.Version.Major >= 6) { var sii = new NativeMethods.SHSTOCKICONINFO(); sii.cbSize = (UInt32)Marshal.SizeOf(typeof(NativeMethods.SHSTOCKICONINFO)); Marshal.ThrowExceptionForHR(NativeMethods.SHGetStockIconInfo(77, 0x0101, ref sii)); try { return Imaging.CreateBitmapSourceFromHIcon( sii.hIcon, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); } finally { NativeMethods.DestroyIcon(sii.hIcon); } } else { return Imaging.CreateBitmapSourceFromHIcon( SystemIcons.Shield.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); } }