Changeset 2771
- Timestamp:
- 7/3/2012 4:36:58 AM (11 months ago)
- Location:
- branches/eraser6/EraserService
- Files:
-
- 6 edited
-
Eraser.Util/NativeMethods/Shell.cs (modified) (1 diff)
-
Eraser.Util/Shell.cs (modified) (2 diffs)
-
Eraser/MainForm.Designer.cs (modified) (4 diffs)
-
Eraser/MainForm.cs (modified) (1 diff)
-
Eraser/MainForm.resx (modified) (5 diffs)
-
Eraser/Program.cs (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/EraserService/Eraser.Util/NativeMethods/Shell.cs
r2523 r2771 451 451 internal static extern uint SHGetKnownFolderPath( 452 452 ref Guid rfid, uint dwFlags, IntPtr hToken, out IntPtr ppszPath); 453 454 /// <summary> 455 /// Retrieves information about system-defined Shell icons. 456 /// </summary> 457 /// <param name="siid">One of the values from the SHGetStockIcons enumeration that 458 /// specifies which icon should be retrieved.</param> 459 /// <param name="uFlags">A combination of zero or more of the SHGetStockIconInfo 460 /// flags that specify which information is requested.</param> 461 /// <param name="psii">A pointer to a SHSTOCKICONINFO structure. When this function 462 /// is called, the cbSize member of this structure needs to be set to the size of 463 /// the SHSTOCKICONINFO structure. When this function returns, contains a pointer 464 /// to a SHSTOCKICONINFO structure that contains the requested information.</param> 465 /// <returns></returns> 466 [DllImport("Shell32.dll", CharSet = CharSet.Unicode)] 467 [return: MarshalAs(UnmanagedType.Error)] 468 internal static extern uint SHGetStockIconInfo(SHStockIcons siid, 469 ShGetStockIconInfoFlags uFlags, ref SHSTOCKICONINFO psii); 470 471 public enum SHStockIcons 472 { 473 SIID_DOCNOASSOC = 0, // document (blank page), no associated program 474 SIID_DOCASSOC = 1, // document with an associated program 475 SIID_APPLICATION = 2, // generic application with no custom icon 476 SIID_FOLDER = 3, // folder (closed) 477 SIID_FOLDEROPEN = 4, // folder (open) 478 SIID_DRIVE525 = 5, // 5.25" floppy disk drive 479 SIID_DRIVE35 = 6, // 3.5" floppy disk drive 480 SIID_DRIVEREMOVE = 7, // removable drive 481 SIID_DRIVEFIXED = 8, // fixed (hard disk) drive 482 SIID_DRIVENET = 9, // network drive 483 SIID_DRIVENETDISABLED = 10, // disconnected network drive 484 SIID_DRIVECD = 11, // CD drive 485 SIID_DRIVERAM = 12, // RAM disk drive 486 SIID_WORLD = 13, // entire network 487 SIID_SERVER = 15, // a computer on the network 488 SIID_PRINTER = 16, // printer 489 SIID_MYNETWORK = 17, // My network places 490 SIID_FIND = 22, // Find 491 SIID_HELP = 23, // Help 492 SIID_SHARE = 28, // overlay for shared items 493 SIID_LINK = 29, // overlay for shortcuts to items 494 SIID_SLOWFILE = 30, // overlay for slow items 495 SIID_RECYCLER = 31, // empty recycle bin 496 SIID_RECYCLERFULL = 32, // full recycle bin 497 SIID_MEDIACDAUDIO = 40, // Audio CD Media 498 SIID_LOCK = 47, // Security lock 499 SIID_AUTOLIST = 49, // AutoList 500 SIID_PRINTERNET = 50, // Network printer 501 SIID_SERVERSHARE = 51, // Server share 502 SIID_PRINTERFAX = 52, // Fax printer 503 SIID_PRINTERFAXNET = 53, // Networked Fax Printer 504 SIID_PRINTERFILE = 54, // Print to File 505 SIID_STACK = 55, // Stack 506 SIID_MEDIASVCD = 56, // SVCD Media 507 SIID_STUFFEDFOLDER = 57, // Folder containing other items 508 SIID_DRIVEUNKNOWN = 58, // Unknown drive 509 SIID_DRIVEDVD = 59, // DVD Drive 510 SIID_MEDIADVD = 60, // DVD Media 511 SIID_MEDIADVDRAM = 61, // DVD-RAM Media 512 SIID_MEDIADVDRW = 62, // DVD-RW Media 513 SIID_MEDIADVDR = 63, // DVD-R Media 514 SIID_MEDIADVDROM = 64, // DVD-ROM Media 515 SIID_MEDIACDAUDIOPLUS = 65, // CD+ (Enhanced CD) Media 516 SIID_MEDIACDRW = 66, // CD-RW Media 517 SIID_MEDIACDR = 67, // CD-R Media 518 SIID_MEDIACDBURN = 68, // Burning CD 519 SIID_MEDIABLANKCD = 69, // Blank CD Media 520 SIID_MEDIACDROM = 70, // CD-ROM Media 521 SIID_AUDIOFILES = 71, // Audio files 522 SIID_IMAGEFILES = 72, // Image files 523 SIID_VIDEOFILES = 73, // Video files 524 SIID_MIXEDFILES = 74, // Mixed files 525 SIID_FOLDERBACK = 75, // Folder back 526 SIID_FOLDERFRONT = 76, // Folder front 527 SIID_SHIELD = 77, // Security shield. Use for UAC prompts only. 528 SIID_WARNING = 78, // Warning 529 SIID_INFO = 79, // Informational 530 SIID_ERROR = 80, // Error 531 SIID_KEY = 81, // Key / Secure 532 SIID_SOFTWARE = 82, // Software 533 SIID_RENAME = 83, // Rename 534 SIID_DELETE = 84, // Delete 535 SIID_MEDIAAUDIODVD = 85, // Audio DVD Media 536 SIID_MEDIAMOVIEDVD = 86, // Movie DVD Media 537 SIID_MEDIAENHANCEDCD = 87, // Enhanced CD Media 538 SIID_MEDIAENHANCEDDVD = 88, // Enhanced DVD Media 539 SIID_MEDIAHDDVD = 89, // HD-DVD Media 540 SIID_MEDIABLURAY = 90, // BluRay Media 541 SIID_MEDIAVCD = 91, // VCD Media 542 SIID_MEDIADVDPLUSR = 92, // DVD+R Media 543 SIID_MEDIADVDPLUSRW = 93, // DVD+RW Media 544 SIID_DESKTOPPC = 94, // desktop computer 545 SIID_MOBILEPC = 95, // mobile computer (laptop/notebook) 546 SIID_USERS = 96, // users 547 SIID_MEDIASMARTMEDIA = 97, // Smart Media 548 SIID_MEDIACOMPACTFLASH = 98, // Compact Flash 549 SIID_DEVICECELLPHONE = 99, // Cell phone 550 SIID_DEVICECAMERA = 100, // Camera 551 SIID_DEVICEVIDEOCAMERA = 101, // Video camera 552 SIID_DEVICEAUDIOPLAYER = 102, // Audio player 553 SIID_NETWORKCONNECT = 103, // Connect to network 554 SIID_INTERNET = 104, // Internet 555 SIID_ZIPFILE = 105, // ZIP file 556 SIID_SETTINGS = 106, // Settings 557 // 107-131 are internal Vista RTM icons 558 // 132-159 for SP1 icons 559 SIID_DRIVEHDDVD = 132, // HDDVD Drive (all types) 560 SIID_DRIVEBD = 133, // BluRay Drive (all types) 561 SIID_MEDIAHDDVDROM = 134, // HDDVD-ROM Media 562 SIID_MEDIAHDDVDR = 135, // HDDVD-R Media 563 SIID_MEDIAHDDVDRAM = 136, // HDDVD-RAM Media 564 SIID_MEDIABDROM = 137, // BluRay ROM Media 565 SIID_MEDIABDR = 138, // BluRay R Media 566 SIID_MEDIABDRE = 139, // BluRay RE Media (Rewriable and RAM) 567 SIID_CLUSTEREDDRIVE = 140, // Clustered disk 568 // 160+ are for Windows 7 icons 569 SIID_MAX_ICONS = 174, 570 } 571 572 [Flags] 573 public enum ShGetStockIconInfoFlags 574 { 575 /// <summary> 576 /// The szPath and iIcon members of the SHSTOCKICONINFO structure receive the path 577 /// and icon index of the requested icon, in a format suitable for passing to the 578 /// ExtractIcon function. The numerical value of this flag is zero, so you always 579 /// get the icon location regardless of other flags. 580 /// </summary> 581 SHGSI_ICONLOCATION = 0, 582 583 /// <summary> 584 /// The hIcon member of the SHSTOCKICONINFO structure receives a handle to the 585 /// specified icon. 586 /// </summary> 587 SHGSI_ICON = 0x000000100, 588 589 /// <summary> 590 /// The iSysImageImage member of the SHSTOCKICONINFO structure receives the index 591 /// of the specified icon in the system imagelist. 592 /// </summary> 593 SHGSI_SYSICONINDEX = 0x000004000, 594 595 /// <summary> 596 /// Modifies the SHGSI_ICON value by causing the function to add the link overlay 597 /// to the file's icon. 598 /// </summary> 599 SHGSI_LINKOVERLAY = 0x000008000, 600 601 /// <summary> 602 /// Modifies the SHGSI_ICON value by causing the function to blend the icon with 603 /// the system highlight color. 604 /// </summary> 605 SHGSI_SELECTED = 0x000010000, 606 607 /// <summary> 608 /// Modifies the SHGSI_ICON value by causing the function to retrieve the large 609 /// version of the icon, as specified by the SM_CXICON and SM_CYICON system metrics. 610 /// </summary> 611 SHGSI_LARGEICON = 0x000000000, 612 613 /// <summary> 614 /// Modifies the SHGSI_ICON value by causing the function to retrieve the small 615 /// version of the icon, as specified by the SM_CXSMICON and SM_CYSMICON system 616 /// metrics. 617 /// </summary> 618 SHGSI_SMALLICON = 0x000000001, 619 620 /// <summary> 621 /// Modifies the SHGSI_LARGEICON or SHGSI_SMALLICON values by causing the function 622 /// to retrieve the Shell-sized icons rather than the sizes specified by the 623 /// system metrics. 624 /// </summary> 625 SHGSI_SHELLICONSIZE = 0x000000004 626 } 627 628 /// <summary> 629 /// Receives information used to retrieve a stock Shell icon. This structure is used 630 /// in a call SHGetStockIconInfo. 631 /// </summary> 632 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] 633 public struct SHSTOCKICONINFO 634 { 635 /// <summary> 636 /// The size of this structure, in bytes. 637 /// </summary> 638 public uint cbSize; 639 640 /// <summary> 641 /// When SHGetStockIconInfo is called with the SHGSI_ICON flag, this member 642 /// receives a handle to the icon. 643 /// </summary> 644 public IntPtr hIcon; 645 646 /// <summary> 647 /// When SHGetStockIconInfo is called with the SHGSI_SYSICONINDEX flag, this member 648 /// receives the index of the image in the system icon cache. 649 /// </summary> 650 public int iSysImageIndex; 651 652 /// <summary> 653 /// When SHGetStockIconInfo is called with the SHGSI_ICONLOCATION flag, this member 654 /// receives the index of the icon in the resource whose path is received in szPath. 655 /// </summary> 656 public int iIcon; 657 658 /// <summary> 659 /// When SHGetStockIconInfo is called with the SHGSI_ICONLOCATION flag, this member 660 /// receives the path of the resource that contains the icon. The index of the icon 661 /// within the resource is received in iIcon. 662 /// </summary> 663 [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxPath)] 664 public char[] szPath; 665 } 453 666 } 454 667 } -
branches/eraser6/EraserService/Eraser.Util/Shell.cs
r2544 r2771 28 28 using Microsoft.Win32; 29 29 using System.IO; 30 using System.Drawing; 30 31 31 32 namespace Eraser.Util … … 67 68 } 68 69 } 70 } 71 72 public enum StockIcon 73 { 74 Shield = NativeMethods.SHStockIcons.SIID_SHIELD 75 } 76 77 /// <summary> 78 /// Gets the stock icon for the given identifier. 79 /// </summary> 80 /// <param name="icon">The icon to look up.</param> 81 /// <returns>A stock icon for the given identifier, or null if the icon cannot 82 /// be found.</returns> 83 public static Icon GetStockIcon(StockIcon icon) 84 { 85 NativeMethods.SHSTOCKICONINFO stockIconInfo = new NativeMethods.SHSTOCKICONINFO(); 86 stockIconInfo.cbSize = (uint)Marshal.SizeOf(stockIconInfo); 87 88 if (NativeMethods.SHGetStockIconInfo((NativeMethods.SHStockIcons)icon, 89 NativeMethods.ShGetStockIconInfoFlags.SHGSI_ICON | 90 NativeMethods.ShGetStockIconInfoFlags.SHGSI_SMALLICON, ref stockIconInfo) == 0) 91 { 92 return Icon.FromHandle(stockIconInfo.hIcon); 93 } 94 95 return null; 69 96 } 70 97 -
branches/eraser6/EraserService/Eraser/MainForm.Designer.cs
r2737 r2771 59 59 this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator(); 60 60 this.hideWhenMinimisedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 61 this.restartAsAdministratorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 61 62 this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 62 63 this.notificationIconTimer = new System.Windows.Forms.Timer(this.components); … … 115 116 this.toolStripMenuItem1, 116 117 this.hideWhenMinimisedToolStripMenuItem, 118 this.restartAsAdministratorToolStripMenuItem, 117 119 this.exitToolStripMenuItem}); 118 120 this.notificationMenu.Name = "notificationMenu"; 119 121 resources.ApplyResources(this.notificationMenu, "notificationMenu"); 122 this.notificationMenu.Opening += new System.ComponentModel.CancelEventHandler(this.notificationMenu_Opening); 120 123 // 121 124 // openEraserToolStripMenuItem … … 136 139 resources.ApplyResources(this.hideWhenMinimisedToolStripMenuItem, "hideWhenMinimisedToolStripMenuItem"); 137 140 this.hideWhenMinimisedToolStripMenuItem.Click += new System.EventHandler(this.hideWhenMinimiseToolStripMenuItem_Click); 141 // 142 // restartAsAdministratorToolStripMenuItem 143 // 144 this.restartAsAdministratorToolStripMenuItem.Name = "restartAsAdministratorToolStripMenuItem"; 145 resources.ApplyResources(this.restartAsAdministratorToolStripMenuItem, "restartAsAdministratorToolStripMenuItem"); 146 this.restartAsAdministratorToolStripMenuItem.Click += new System.EventHandler(this.restartAsAdministratorToolStripMenuItem_Click); 138 147 // 139 148 // exitToolStripMenuItem … … 346 355 private System.Windows.Forms.ToolStripMenuItem tbToolsDropDown; 347 356 private System.Windows.Forms.ContextMenuStrip tbToolsMenu; 357 private System.Windows.Forms.ToolStripMenuItem restartAsAdministratorToolStripMenuItem; 348 358 } 349 359 } -
branches/eraser6/EraserService/Eraser/MainForm.cs
r2756 r2771 555 555 } 556 556 #endregion 557 558 private void notificationMenu_Opening(object sender, CancelEventArgs e) 559 { 560 //Hide the restart as administrator menu item if we are already running as an 561 //administrator 562 if (Security.IsAdministrator()) 563 restartAsAdministratorToolStripMenuItem.Visible = false; 564 else 565 { 566 //Otherwise only allow that if we are on Vista+ 567 if (Environment.OSVersion.Platform != PlatformID.Win32NT || 568 Environment.OSVersion.Version < new Version(6, 0)) 569 { 570 restartAsAdministratorToolStripMenuItem.Visible = false; 571 } 572 else if (restartAsAdministratorToolStripMenuItem.Image == null) 573 { 574 restartAsAdministratorToolStripMenuItem.Image = 575 Shell.GetStockIcon(Shell.StockIcon.Shield).ToBitmap(); 576 } 577 } 578 } 579 580 private void restartAsAdministratorToolStripMenuItem_Click(object sender, EventArgs e) 581 { 582 Program.eraserClient.Exit(); 583 Application.Exit(); 584 } 557 585 } 558 586 -
branches/eraser6/EraserService/Eraser/MainForm.resx
r2737 r2771 160 160 <value>801, 17</value> 161 161 </metadata> 162 <data name="openEraserToolStripMenuItem.Font" type="System.Drawing.Font, System.Drawing"> 163 <value>Microsoft Sans Serif, 9pt, style=Bold</value> 164 </data> 165 <data name="openEraserToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing"> 166 <value>200, 22</value> 167 </data> 168 <data name="openEraserToolStripMenuItem.Text" xml:space="preserve"> 169 <value>&Open Eraser</value> 170 </data> 171 <data name="toolStripMenuItem1.Size" type="System.Drawing.Size, System.Drawing"> 172 <value>197, 6</value> 173 </data> 174 <data name="hideWhenMinimisedToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing"> 175 <value>200, 22</value> 176 </data> 177 <data name="hideWhenMinimisedToolStripMenuItem.Text" xml:space="preserve"> 178 <value>&Hide When Minimised</value> 179 </data> 180 <data name="restartAsAdministratorToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing"> 181 <value>200, 22</value> 182 </data> 183 <data name="restartAsAdministratorToolStripMenuItem.Text" xml:space="preserve"> 184 <value>Restart as &Administrator</value> 185 </data> 186 <data name="exitToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing"> 187 <value>200, 22</value> 188 </data> 189 <data name="exitToolStripMenuItem.Text" xml:space="preserve"> 190 <value>E&xit Eraser</value> 191 </data> 162 192 <data name="notificationMenu.Size" type="System.Drawing.Size, System.Drawing"> 163 <value> 193, 76</value>193 <value>201, 120</value> 164 194 </data> 165 195 <data name=">>notificationMenu.Name" xml:space="preserve"> … … 1735 1765 <value>True</value> 1736 1766 </data> 1737 <data name="openEraserToolStripMenuItem.Font" type="System.Drawing.Font, System.Drawing">1738 <value>Microsoft Sans Serif, 9pt, style=Bold</value>1739 </data>1740 <data name="openEraserToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">1741 <value>192, 22</value>1742 </data>1743 <data name="openEraserToolStripMenuItem.Text" xml:space="preserve">1744 <value>Open Eraser</value>1745 </data>1746 <data name="toolStripMenuItem1.Size" type="System.Drawing.Size, System.Drawing">1747 <value>189, 6</value>1748 </data>1749 <data name="hideWhenMinimisedToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">1750 <value>192, 22</value>1751 </data>1752 <data name="hideWhenMinimisedToolStripMenuItem.Text" xml:space="preserve">1753 <value>Hide When Minimised</value>1754 </data>1755 <data name="exitToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">1756 <value>192, 22</value>1757 </data>1758 <data name="exitToolStripMenuItem.Text" xml:space="preserve">1759 <value>E&xit Eraser</value>1760 </data>1761 1767 <metadata name="notificationIconTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 1762 1768 <value>634, 17</value> … … 1768 1774 <value>None</value> 1769 1775 </data> 1770 <data name="ToolBar.Location" type="System.Drawing.Point, System.Drawing">1771 <value>10, 27</value>1772 </data>1773 <data name="ToolBar.Size" type="System.Drawing.Size, System.Drawing">1774 <value>392, 32</value>1775 </data>1776 <data name="ToolBar.TabIndex" type="System.Int32, mscorlib">1777 <value>1</value>1778 </data>1779 <data name="ToolBar.Text" xml:space="preserve">1780 <value>ToolBar</value>1781 </data>1782 <data name=">>ToolBar.Name" xml:space="preserve">1783 <value>ToolBar</value>1784 </data>1785 <data name=">>ToolBar.Type" xml:space="preserve">1786 <value>Eraser.ToolBar, Eraser, Version=6.1.0.2532, Culture=neutral, PublicKeyToken=3ac89a0351e689b6</value>1787 </data>1788 <data name=">>ToolBar.Parent" xml:space="preserve">1789 <value>$this</value>1790 </data>1791 <data name=">>ToolBar.ZOrder" xml:space="preserve">1792 <value>6</value>1793 </data>1794 1776 <metadata name="tbScheduleMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 1795 1777 <value>110, 17</value> … … 1917 1899 <data name="tbHelpDropDown.Text" xml:space="preserve"> 1918 1900 <value>Help</value> 1901 </data> 1902 <data name="ToolBar.Location" type="System.Drawing.Point, System.Drawing"> 1903 <value>10, 27</value> 1904 </data> 1905 <data name="ToolBar.Size" type="System.Drawing.Size, System.Drawing"> 1906 <value>392, 32</value> 1907 </data> 1908 <data name="ToolBar.TabIndex" type="System.Int32, mscorlib"> 1909 <value>1</value> 1910 </data> 1911 <data name="ToolBar.Text" xml:space="preserve"> 1912 <value>ToolBar</value> 1913 </data> 1914 <data name=">>ToolBar.Name" xml:space="preserve"> 1915 <value>ToolBar</value> 1916 </data> 1917 <data name=">>ToolBar.Type" xml:space="preserve"> 1918 <value>Eraser.ToolBar, Eraser, Version=6.1.0.2671, Culture=neutral, PublicKeyToken=5fdae78f3f1dcf4a</value> 1919 </data> 1920 <data name=">>ToolBar.Parent" xml:space="preserve"> 1921 <value>$this</value> 1922 </data> 1923 <data name=">>ToolBar.ZOrder" xml:space="preserve"> 1924 <value>6</value> 1919 1925 </data> 1920 1926 <data name="checkForUpdatesToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing"> … … 3559 3565 <value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 3560 3566 </data> 3567 <data name=">>restartAsAdministratorToolStripMenuItem.Name" xml:space="preserve"> 3568 <value>restartAsAdministratorToolStripMenuItem</value> 3569 </data> 3570 <data name=">>restartAsAdministratorToolStripMenuItem.Type" xml:space="preserve"> 3571 <value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 3572 </data> 3561 3573 <data name=">>exitToolStripMenuItem.Name" xml:space="preserve"> 3562 3574 <value>exitToolStripMenuItem</value> -
branches/eraser6/EraserService/Eraser/Program.cs
r2761 r2771 725 725 /// The global Executor instance. 726 726 /// </summary> 727 public static ExecutoreraserClient;727 public static RemoteExecutorClient eraserClient; 728 728 } 729 729
Note: See TracChangeset
for help on using the changeset viewer.
