Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
3.1 KiB

  1. namespace WindowsApplication1
  2. {
  3. //This Form is only used to show services or drivers properties
  4. using System;
  5. using System.Drawing;
  6. using System.Collections;
  7. using System.ComponentModel;
  8. using System.Windows.Forms;
  9. // Summary description for ServiceInfo.
  10. // Show some service's properties
  11. public class ServiceInfo : System.Windows.Forms.Form
  12. {
  13. // Required designer variable
  14. private System.ComponentModel.Container components;
  15. private System.Windows.Forms.Button btnClose;
  16. private System.Windows.Forms.ListBox lstInfo;
  17. //Explicit constructor
  18. public ServiceInfo(System.ServiceProcess.ServiceController tmpServCtrl)
  19. {
  20. InitializeComponent();
  21. ShowInfo(tmpServCtrl);
  22. }
  23. protected override void Dispose( bool disposing )
  24. {
  25. if( disposing )
  26. {
  27. if (components != null)
  28. {
  29. components.Dispose();
  30. }
  31. }
  32. base.Dispose( disposing );
  33. }
  34. // Required method for Designer support - do not modify
  35. // the contents of this method with the code editor
  36. private void InitializeComponent()
  37. {
  38. this.components = new System.ComponentModel.Container ();
  39. this.btnClose = new System.Windows.Forms.Button ();
  40. this.lstInfo = new System.Windows.Forms.ListBox ();
  41. //@this.TrayHeight = 0;
  42. //@this.TrayLargeIcon = false;
  43. //@this.TrayAutoArrange = true;
  44. this.Text = "ServiceInfo";
  45. this.AutoScaleBaseSize = new System.Drawing.Size (5, 13);
  46. this.ClientSize = new System.Drawing.Size (672, 517);
  47. btnClose.Location = new System.Drawing.Point (280, 464);
  48. btnClose.Size = new System.Drawing.Size (112, 24);
  49. btnClose.TabIndex = 1;
  50. btnClose.Text = "Close";
  51. btnClose.Click += new System.EventHandler (this.btnClose_Click);
  52. lstInfo.Location = new System.Drawing.Point (8, 8);
  53. lstInfo.Size = new System.Drawing.Size (656, 429);
  54. lstInfo.Font = new System.Drawing.Font ("Microsoft Sans Serif", 16, System.Drawing.FontStyle.Bold);
  55. lstInfo.TabIndex = 0;
  56. this.Controls.Add (this.btnClose);
  57. this.Controls.Add (this.lstInfo);
  58. }
  59. protected void btnClose_Click(object sender, System.EventArgs e)
  60. {
  61. this.Close();
  62. }
  63. //Get some Service Info
  64. private void ShowInfo(System.ServiceProcess.ServiceController tmpSrvCtrl)
  65. {
  66. try
  67. {
  68. lstInfo.Items.Add("ServiceName: " + tmpSrvCtrl.ServiceName);
  69. lstInfo.Items.Add("Service Status: "+ tmpSrvCtrl.Status.ToString());
  70. lstInfo.Items.Add("DisplayName: " + tmpSrvCtrl.DisplayName);
  71. lstInfo.Items.Add("MachineName: " + tmpSrvCtrl.MachineName);
  72. lstInfo.Items.Add("CanPauseAndContinue: " + tmpSrvCtrl.CanPauseAndContinue.ToString());
  73. lstInfo.Items.Add("CanShutdown: " + tmpSrvCtrl.CanShutdown.ToString());
  74. lstInfo.Items.Add("*************** Dependent Services ********************");
  75. //Check for the Dependent services (if any)
  76. foreach (System.ServiceProcess.ServiceController s in tmpSrvCtrl.DependentServices )
  77. {
  78. lstInfo.Items.Add(s.ServiceName + " is " + s.Status.ToString() );
  79. }
  80. }
  81. catch
  82. {
  83. MessageBox.Show("Couldn't read Service Info!");
  84. }
  85. }
  86. }
  87. }