public static void SetUACShield(this Button @this, bool showShield = true) { if (!ChoWindowsIdentity.IsAdministrator() && ChoEnvironment.AtLeastVista()) { //Note: make sure the button FlatStyle = FlatStyle.System @this.FlatStyle = FlatStyle.System; // BCM_SETSHIELD = 0x0000160C ChoUser32.SendMessage(@this.Handle, ChoUser32.BCM_SETSHIELD, 0, showShield ? 0xFFFFFFFF : 0); } }
public static void SetUACShield(this ToolStripMenuItem @this, bool showShield = true) { if (!ChoWindowsIdentity.IsAdministrator() && ChoEnvironment.AtLeastVista()) { //SHSTOCKICONINFO iconResult = new SHSTOCKICONINFO(); //iconResult.cbSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(iconResult); //ChoShell32.SHGetStockIconInfo( // SHSTOCKICONID.SIID_SHIELD, // SHGSI.SHGSI_ICON | SHGSI.SHGSI_SMALLICON, // ref iconResult); //@this.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText; //@this.Image = Bitmap.FromHicon(iconResult.hIcon); @this.ImageScaling = ToolStripItemImageScaling.None; @this.Image = ChoEnvironment.GetUACShieldImage(); } }