Ejemplo n.º 1
0
        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()));
            }
        }
Ejemplo n.º 2
0
        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());
            }
        }