Esempio n. 1
0
        public ShieldIcon()
        {
            const int SIID_SHIELD = 77;
            const uint SHGFI_ICON = 0x100;
            const uint SHGFI_SMALLICON = 0x1;

            // NT6 kernelかどうか検査
            if (!IsNT6())
            {
                _icondata = null;
                return;
            }

            try
            {
                _sii = new SHSTOCKICONINFO();
                _sii.cbSize = Marshal.SizeOf(_sii);
                _sii.hIcon = IntPtr.Zero;
                SHGetStockIconInfo(SIID_SHIELD, SHGFI_ICON | SHGFI_SMALLICON, ref _sii);
                _icondata = Bitmap.FromHicon(_sii.hIcon);
            }
            catch (Exception)
            {
                _icondata = null;
            }
        }
Esempio n. 2
0
        public ShieldIcon()
        {
            //NT6 kernelかどうか検査
            if (!MyCommon.IsNT6())
            {
                icondata = null;
                return;
            }

            try
            {
                sii = new SHSTOCKICONINFO();
                sii.cbSize = Marshal.SizeOf(sii);
                sii.hIcon = IntPtr.Zero;

                int ret;
                ret = SHGetStockIconInfo(SIID_SHIELD, SHGFI_ICON | SHGFI_SMALLICON, ref sii);
                if (ret != 0)
                {
                    icondata = null;
                    return;
                }

                icondata = Bitmap.FromHicon(sii.hIcon);
            }
            catch (Exception)
            {
                icondata = null;
            }
        }
Esempio n. 3
0
        private static Icon GetStockIcon(int id, SHGSI flags)
        {
            SHSTOCKICONINFO info = new SHSTOCKICONINFO();
            info.cbSize = Marshal.SizeOf(typeof(SHSTOCKICONINFO));
            if (SHGetStockIconInfo(id, flags, ref info) == 0)
                return Icon.FromHandle(info.hIcon);

            return null;
        }
Esempio n. 4
0
        static UacImageSource()
        {
            SHSTOCKICONINFO sii = new SHSTOCKICONINFO();
            sii.cbSize = (UInt32)Marshal.SizeOf(typeof(SHSTOCKICONINFO));

            Marshal.ThrowExceptionForHR(NativeMethods.SHGetStockIconInfo(SHSTOCKICONID.SIID_SHIELD,
                SHGSI.SHGSI_ICON | SHGSI.SHGSI_SMALLICON,
                ref sii));

            Shield = Imaging.CreateBitmapSourceFromHIcon(sii.hIcon, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());

            NativeMethods.DestroyIcon(sii.hIcon);
        }
        public static BitmapSource GetShield()
        {
            SHSTOCKICONINFO sii = new SHSTOCKICONINFO();
            sii.cbSize = (uint)Marshal.SizeOf(typeof(SHSTOCKICONINFO));

            Marshal.ThrowExceptionForHR(SHGetStockIconInfo(SHSTOCKICONID.SIID_SHIELD,
                SHGSI.SHGSI_ICON | SHGSI.SHGSI_LARGEICON,
                ref sii));

            BitmapSource shieldSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon(
                sii.hIcon,
                Int32Rect.Empty,
                BitmapSizeOptions.FromEmptyOptions());

            DestroyIcon(sii.hIcon);

            return shieldSource;
        }
 public static extern int SHGetStockIconInfo(uint siid, uint uFlags, ref SHSTOCKICONINFO psii);
Esempio n. 7
0
 private static extern int SHGetStockIconInfo(int siid, uint flags, ref SHSTOCKICONINFO psii);
Esempio n. 8
0
        public static System.Windows.Media.Imaging.BitmapSource GetShieldIcon()
        {
            System.Windows.Media.Imaging.BitmapSource shield = null;
            SHSTOCKICONINFO sii = new SHSTOCKICONINFO();
            sii.cbSize = (UInt32)Marshal.SizeOf(typeof(SHSTOCKICONINFO));

            Marshal.ThrowExceptionForHR(SHGetStockIconInfo(SHSTOCKICONID.SIID_SHIELD,
                SHGSI.SHGSI_ICON | SHGSI.SHGSI_SMALLICON,
                ref sii));

            shield = System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon(
                sii.HICON,
                Int32Rect.Empty,
                System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
            DestroyIcon(sii.HICON);
            return shield;
        }
Esempio n. 9
0
 private static extern HRESULT SHGetStockIconInfo(SHSTOCKICONID siid, SHGetStockIconInfoFlags uFlags,
     ref SHSTOCKICONINFO psii);
Esempio n. 10
0
 private static extern Int32 SHGetStockIconInfo(uint siid, uint uFlags, ref SHSTOCKICONINFO psii);
 public static extern HRESULT SHGetStockIconInfo(SHSTOCKICONID siid, SHGSI uFlags, ref SHSTOCKICONINFO psii);
Esempio n. 12
0
 public static extern void SHGetStockIconInfo(UInt32 siid, UInt32 uFlags, ref SHSTOCKICONINFO sii);
Esempio n. 13
0
 private static extern int SHGetStockIconInfo(SHSTOCKICONID siid, SHGSI uFlags, ref SHSTOCKICONINFO psii);
Esempio n. 14
0
 static extern Int32 SHGetStockIconInfo(SHSTOCKICONID siid, SHGSI uFlags, ref SHSTOCKICONINFO psii);
Esempio n. 15
0
        public static BitmapSource GetShieldIcon()
        {
            if (Environment.OSVersion.Version.Major >= 6)
            {
                SHSTOCKICONINFO sii = new SHSTOCKICONINFO();
                sii.cbSize = (UInt32) Marshal.SizeOf(typeof(SHSTOCKICONINFO));

                Marshal.ThrowExceptionForHR(SHGetStockIconInfo(SHSTOCKICONID.SIID_SHIELD,
                    SHGSI.SHGSI_ICON | SHGSI.SHGSI_SMALLICON,
                    ref sii));
                try
                {
                    return System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon(
                        sii.hIcon,
                        Int32Rect.Empty,
                        BitmapSizeOptions.FromEmptyOptions());
                }
                finally
                {
                    DestroyIcon(sii.hIcon);
                }
            }
            else
            {
                return System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon(
                    System.Drawing.SystemIcons.Shield.Handle,
                    Int32Rect.Empty,
                    BitmapSizeOptions.FromEmptyOptions());
            }
        }
 public static extern int SHGetStockIconInfo(uint siid, uint uFlags, ref SHSTOCKICONINFO psii);
Esempio n. 17
0
 public static extern Int32 SHGetStockIconInfo(SHSTOCKICONID siid, SHGSI uFlags, ref SHSTOCKICONINFO psii);
Esempio n. 18
0
 public static extern uint SHGetStockIconInfo(
     SHSTOCKICONID siid,
     SHGetStockIconFlags uFlags,
     ref SHSTOCKICONINFO psii);