コード例 #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()));
            }
        }
コード例 #2
0
ファイル: Controls.cs プロジェクト: AlexanderSher/RTVS-Old
        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());
            }
        }