打印

[原创] 小程序

本主题由 小3 于 2008-8-23 19:02 移动

小程序

小弟我做的东西有点烂,请大家包涵,^ ^这是我第一次做的所以还要请大家多指点。
可以用Microsoft Visual Studio 2003来运行 ,用c#写的 ~

本程序的功能:
1 能够显示系统服务信息
2 能够显示系统进程信息
3 可以设置开机自动启动程序
4 可以禁止/允许关闭操作系统
5 可扫描主机端口
6 可以隐藏/显示本机磁盘盘服

请问版主现在为什么不能够传附件了呢?
我记得原来可以的啊?
能否给个解释呢?
谢谢~

郁闷,只能把下面的代码给大家了~
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.ServiceProcess;
using System.Diagnostics;
using Microsoft.Win32;
using System.Net.Sockets;
namespace System
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
  private System.Windows.Forms.ListBox listBox1;
  private System.Windows.Forms.Button button1;
  private System.Windows.Forms.Button button2;
  private System.Windows.Forms.Button button4;
  private System.Windows.Forms.Button button5;
  private System.Windows.Forms.Button button6;
  private System.Windows.Forms.ListView listView1;
  private System.Windows.Forms.ColumnHeader columnHeader1;
  private System.Windows.Forms.ColumnHeader columnHeader2;
  private System.Windows.Forms.Label label1;
  private System.Windows.Forms.Label label2;
  private System.Windows.Forms.Button button7;
  private System.Windows.Forms.Button button8;
  private System.Windows.Forms.Button button9;
  private System.Windows.Forms.TextBox textBox1;
  private System.Windows.Forms.Label label3;
  private System.Windows.Forms.Label label4;
  private System.Windows.Forms.OpenFileDialog openFileDialog1;
  private System.Windows.Forms.Label label7;
  private System.Windows.Forms.Label label9;
  private System.Windows.Forms.Label label10;
  private System.Windows.Forms.Label label11;
  private System.Windows.Forms.ProgressBar progressBar1;
        private System.Windows.Forms.RichTextBox richTextBox1;
  private System.Windows.Forms.NumericUpDown numericUpDown2;
  private System.Windows.Forms.Label label6;
  private System.Windows.Forms.NumericUpDown numericUpDown1;
  private System.Windows.Forms.Label label8;
  private System.Windows.Forms.TextBox textBox2;
  private System.Windows.Forms.Label label12;
  private System.Windows.Forms.Panel panel1;
  private System.Windows.Forms.Button button10;
  private System.Windows.Forms.CheckedListBox checkedListBox1;
  private System.Windows.Forms.Button button11;
  private System.Windows.Forms.Label label5;
        private Button button3;
  /// <summary>
  /// 必需的设计器变量。
  /// </summary>
  private System.ComponentModel.Container components = null;
  public Form1()
  {
   //
   // Windows 窗体设计器支持所必需的
   //
   InitializeComponent();
   //
   // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
   //
  }
  /// <summary>
  /// 清理所有正在使用的资源。
  /// </summary>
  protected override void Dispose( bool disposing )
  {
   if( disposing )
   {
    if (components != null)
    {
     components.Dispose();
    }
   }
   base.Dispose( disposing );
  }
  #region Windows 窗体设计器生成的代码
  /// <summary>
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  /// </summary>
  private void InitializeComponent()
  {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
            this.listBox1 = new System.Windows.Forms.ListBox();
            this.button1 = new System.Windows.Forms.Button();
            this.button2 = new System.Windows.Forms.Button();
            this.button4 = new System.Windows.Forms.Button();
            this.button5 = new System.Windows.Forms.Button();
            this.button6 = new System.Windows.Forms.Button();
            this.listView1 = new System.Windows.Forms.ListView();
            this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
            this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.button7 = new System.Windows.Forms.Button();
            this.button8 = new System.Windows.Forms.Button();
            this.button9 = new System.Windows.Forms.Button();
            this.textBox1 = new System.Windows.Forms.TextBox();
            this.label3 = new System.Windows.Forms.Label();
            this.label4 = new System.Windows.Forms.Label();
            this.label7 = new System.Windows.Forms.Label();
            this.label9 = new System.Windows.Forms.Label();
            this.label10 = new System.Windows.Forms.Label();
            this.label11 = new System.Windows.Forms.Label();
            this.progressBar1 = new System.Windows.Forms.ProgressBar();
            this.richTextBox1 = new System.Windows.Forms.RichTextBox();
            this.button3 = new System.Windows.Forms.Button();
            this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
            this.label6 = new System.Windows.Forms.Label();
            this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
            this.label8 = new System.Windows.Forms.Label();
            this.textBox2 = new System.Windows.Forms.TextBox();
            this.label12 = new System.Windows.Forms.Label();
            this.panel1 = new System.Windows.Forms.Panel();
            this.button10 = new System.Windows.Forms.Button();
            this.checkedListBox1 = new System.Windows.Forms.CheckedListBox();
            this.button11 = new System.Windows.Forms.Button();
            this.label5 = new System.Windows.Forms.Label();
            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
            this.panel1.SuspendLayout();
            this.SuspendLayout();
            //
            // listBox1
            //
            this.listBox1.Cursor = System.Windows.Forms.Cursors.Hand;
            this.listBox1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
            this.listBox1.ItemHeight = 12;
            this.listBox1.Location = new System.Drawing.Point(32, 48);
            this.listBox1.Name = "listBox1";
            this.listBox1.Size = new System.Drawing.Size(392, 76);
            this.listBox1.TabIndex = 0;
            //
            // button1
            //
            this.button1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(255)))));
            this.button1.Cursor = System.Windows.Forms.Cursors.Hand;
            this.button1.Font = new System.Drawing.Font("仿宋_GB2312", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.button1.ForeColor = System.Drawing.Color.Lime;
            this.button1.Location = new System.Drawing.Point(8, 336);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(112, 24);
            this.button1.TabIndex = 1;
            this.button1.Text = "更新系统服务信息";
            this.button1.UseVisualStyleBackColor = false;
            this.button1.Click += new System.EventHandler(this.button1_Click);
            //
            // button2
            //
            this.button2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(255)))));
            this.button2.Cursor = System.Windows.Forms.Cursors.Hand;
            this.button2.Font = new System.Drawing.Font("仿宋_GB2312", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.button2.ForeColor = System.Drawing.Color.Lime;
            this.button2.Location = new System.Drawing.Point(168, 336);
            this.button2.Name = "button2";
            this.button2.Size = new System.Drawing.Size(112, 24);
            this.button2.TabIndex = 2;
            this.button2.Text = "获取制定服务类型";
            this.button2.UseVisualStyleBackColor = false;
            this.button2.Click += new System.EventHandler(this.button2_Click);
            //
            // button4
            //
            this.button4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(128)))));
            this.button4.Cursor = System.Windows.Forms.Cursors.Hand;
            this.button4.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.button4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(64)))));
            this.button4.Location = new System.Drawing.Point(40, 408);
            this.button4.Name = "button4";
            this.button4.Size = new System.Drawing.Size(352, 24);
            this.button4.TabIndex = 4;
            this.button4.Text = "退          出          程          序";
            this.button4.UseVisualStyleBackColor = false;
            this.button4.Click += new System.EventHandler(this.button4_Click);
            //
            // button5
            //
            this.button5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(255)))));
            this.button5.Cursor = System.Windows.Forms.Cursors.Hand;
            this.button5.Font = new System.Drawing.Font("仿宋_GB2312", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.button5.ForeColor = System.Drawing.Color.Lime;
            this.button5.Location = new System.Drawing.Point(8, 376);
            this.button5.Name = "button5";
            this.button5.Size = new System.Drawing.Size(112, 24);
            this.button5.TabIndex = 5;
            this.button5.Text = "更新系统进程";
            this.button5.UseVisualStyleBackColor = false;
            this.button5.Click += new System.EventHandler(this.button5_Click);
            //
            // button6
            //
            this.button6.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(255)))));
            this.button6.Cursor = System.Windows.Forms.Cursors.Hand;
            this.button6.Font = new System.Drawing.Font("仿宋_GB2312", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.button6.ForeColor = System.Drawing.Color.Lime;
            this.button6.Location = new System.Drawing.Point(168, 376);
            this.button6.Name = "button6";
            this.button6.Size = new System.Drawing.Size(112, 24);
            this.button6.TabIndex = 6;
            this.button6.Text = "终止该进程";
            this.button6.UseVisualStyleBackColor = false;
            this.button6.Click += new System.EventHandler(this.button6_Click);
            //
            // listView1
            //
            this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
            this.columnHeader1,
            this.columnHeader2});
            this.listView1.Cursor = System.Windows.Forms.Cursors.Hand;
            this.listView1.ForeColor = System.Drawing.Color.Magenta;
            this.listView1.FullRowSelect = true;
            this.listView1.GridLines = true;
            this.listView1.Location = new System.Drawing.Point(32, 160);
            this.listView1.MultiSelect = false;
            this.listView1.Name = "listView1";
            this.listView1.Size = new System.Drawing.Size(392, 76);
            this.listView1.TabIndex = 2;
            this.listView1.UseCompatibleStateImageBehavior = false;
            this.listView1.View = System.Windows.Forms.View.Details;
            //
            // columnHeader1
            //
            this.columnHeader1.Text = "进程名称";
            this.columnHeader1.Width = 100;
            //
            // columnHeader2
            //
            this.columnHeader2.Text = "程序窗口标题";
            this.columnHeader2.Width = 300;
            //
            // label1
            //
            this.label1.Font = new System.Drawing.Font("仿宋_GB2312", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.label1.ForeColor = System.Drawing.Color.Lime;
            this.label1.Location = new System.Drawing.Point(32, 136);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(112, 16);
            this.label1.TabIndex = 7;
            this.label1.Text = "进程显示块:";
            //
            // label2
            //
            this.label2.Font = new System.Drawing.Font("仿宋_GB2312", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.label2.ForeColor = System.Drawing.Color.Lime;
            this.label2.Location = new System.Drawing.Point(32, 24);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(112, 16);
            this.label2.TabIndex = 8;
            this.label2.Text = "系统服务显示块:";
            //
            // button7
            //
            this.button7.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(255)))));
            this.button7.Cursor = System.Windows.Forms.Cursors.Hand;
            this.button7.Font = new System.Drawing.Font("仿宋_GB2312", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.button7.ForeColor = System.Drawing.Color.Lime;
            this.button7.Location = new System.Drawing.Point(312, 336);
            this.button7.Name = "button7";
            this.button7.Size = new System.Drawing.Size(112, 24);
            this.button7.TabIndex = 9;
            this.button7.Text = "禁止关闭操作系统";
            this.button7.UseVisualStyleBackColor = false;
            this.button7.Click += new System.EventHandler(this.button7_Click);
            //
            // button8
            //
            this.button8.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(255)))));
            this.button8.Cursor = System.Windows.Forms.Cursors.Hand;
            this.button8.Font = new System.Drawing.Font("仿宋_GB2312", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.button8.ForeColor = System.Drawing.Color.Lime;
            this.button8.Location = new System.Drawing.Point(312, 376);
            this.button8.Name = "button8";
            this.button8.Size = new System.Drawing.Size(112, 24);
            this.button8.TabIndex = 10;
            this.button8.Text = "允许关闭操作系统";
            this.button8.UseVisualStyleBackColor = false;
            this.button8.Click += new System.EventHandler(this.button8_Click);
            //
            // button9
            //
            this.button9.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(255)))));
            this.button9.Cursor = System.Windows.Forms.Cursors.Hand;
            this.button9.Font = new System.Drawing.Font("仿宋_GB2312", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.button9.ForeColor = System.Drawing.Color.Lime;
            this.button9.Location = new System.Drawing.Point(80, 296);
            this.button9.Name = "button9";
            this.button9.Size = new System.Drawing.Size(288, 23);
            this.button9.TabIndex = 14;
            this.button9.Text = "设置自启动程序";
            this.button9.UseVisualStyleBackColor = false;
            this.button9.Click += new System.EventHandler(this.button9_Click);
            //
            // textBox1
            //
            this.textBox1.Location = new System.Drawing.Point(208, 264);
            this.textBox1.Name = "textBox1";
            this.textBox1.Size = new System.Drawing.Size(192, 21);
            this.textBox1.TabIndex = 12;
            //
            // label3
            //
            this.label3.Font = new System.Drawing.Font("仿宋_GB2312", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.label3.ForeColor = System.Drawing.Color.Lime;
            this.label3.Location = new System.Drawing.Point(72, 272);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(80, 16);
            this.label3.TabIndex = 11;
            this.label3.Text = "应用程序名:";
            //
            // label4
            //
            this.label4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(255)))));
            this.label4.Font = new System.Drawing.Font("仿宋_GB2312", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.label4.ForeColor = System.Drawing.Color.Lime;
            this.label4.Location = new System.Drawing.Point(56, 248);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(144, 16);
            this.label4.TabIndex = 15;
            this.label4.Text = "设置开机自动启动程序:";
            //
            // label7
            //
            this.label7.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(255)))));
            this.label7.Font = new System.Drawing.Font("仿宋_GB2312", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.label7.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
            this.label7.Location = new System.Drawing.Point(80, 272);
            this.label7.Name = "label7";
            this.label7.Size = new System.Drawing.Size(80, 16);
            this.label7.TabIndex = 11;
            this.label7.Text = "应用程序名:";
            //
            // label9
            //
            this.label9.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(255)))));
            this.label9.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
            this.label9.Location = new System.Drawing.Point(40, 24);
            this.label9.Name = "label9";
            this.label9.Size = new System.Drawing.Size(112, 16);
            this.label9.TabIndex = 8;
            this.label9.Text = "系统服务显示块:";
            //
            // label10
            //
            this.label10.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
            this.label10.Location = new System.Drawing.Point(40, 136);
            this.label10.Name = "label10";
            this.label10.Size = new System.Drawing.Size(112, 16);
            this.label10.TabIndex = 7;
            this.label10.Text = "进程显示块:";
            //
            // label11
            //
            this.label11.Font = new System.Drawing.Font("仿宋_GB2312", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.label11.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
            this.label11.Location = new System.Drawing.Point(64, 248);
            this.label11.Name = "label11";
            this.label11.Size = new System.Drawing.Size(144, 16);
            this.label11.TabIndex = 15;
            this.label11.Text = "设置开机自动启动程序:";
            //
            // progressBar1
            //
            this.progressBar1.Location = new System.Drawing.Point(424, 280);
            this.progressBar1.Name = "progressBar1";
            this.progressBar1.Size = new System.Drawing.Size(320, 23);
            this.progressBar1.Step = 1;
            this.progressBar1.TabIndex = 28;
            //
            // richTextBox1
            //
            this.richTextBox1.BackColor = System.Drawing.Color.White;
            this.richTextBox1.Cursor = System.Windows.Forms.Cursors.No;
            this.richTextBox1.Location = new System.Drawing.Point(424, 208);
            this.richTextBox1.Name = "richTextBox1";
            this.richTextBox1.Size = new System.Drawing.Size(320, 72);
            this.richTextBox1.TabIndex = 27;
            this.richTextBox1.Text = "";
            //
            // button3
            //
            this.button3.Cursor = System.Windows.Forms.Cursors.Hand;
            this.button3.Location = new System.Drawing.Point(664, 184);
            this.button3.Name = "button3";
            this.button3.Size = new System.Drawing.Size(80, 23);
            this.button3.TabIndex = 26;
            this.button3.Text = "开始扫描";
            this.button3.Click += new System.EventHandler(this.button3_Click_1);
            //
            // numericUpDown2
            //
            this.numericUpDown2.Cursor = System.Windows.Forms.Cursors.IBeam;
            this.numericUpDown2.Location = new System.Drawing.Point(504, 184);
            this.numericUpDown2.Maximum = new decimal(new int[] {
            65536,
            0,
            0,
            0});
            this.numericUpDown2.Name = "numericUpDown2";
            this.numericUpDown2.Size = new System.Drawing.Size(72, 21);
            this.numericUpDown2.TabIndex = 25;
            this.numericUpDown2.Value = new decimal(new int[] {
            50,
            0,
            0,
            0});
            //
            // label6
            //
            this.label6.Location = new System.Drawing.Point(424, 192);
            this.label6.Name = "label6";
            this.label6.Size = new System.Drawing.Size(80, 16);
            this.label6.TabIndex = 24;
            this.label6.Text = "结束端口号:";
            //
            // numericUpDown1
            //
            this.numericUpDown1.Cursor = System.Windows.Forms.Cursors.IBeam;
            this.numericUpDown1.Location = new System.Drawing.Point(664, 168);
            this.numericUpDown1.Maximum = new decimal(new int[] {
            65536,
            0,
            0,
            0});
            this.numericUpDown1.Name = "numericUpDown1";
            this.numericUpDown1.Size = new System.Drawing.Size(80, 21);
            this.numericUpDown1.TabIndex = 23;
            //
            // label8
            //
            this.label8.Location = new System.Drawing.Point(584, 168);
            this.label8.Name = "label8";
            this.label8.Size = new System.Drawing.Size(80, 16);
            this.label8.TabIndex = 22;
            this.label8.Text = "起始端口号:";
            //
            // textBox2
            //
            this.textBox2.Cursor = System.Windows.Forms.Cursors.IBeam;
            this.textBox2.Location = new System.Drawing.Point(504, 168);
            this.textBox2.Name = "textBox2";
            this.textBox2.Size = new System.Drawing.Size(72, 21);
            this.textBox2.TabIndex = 21;
            this.textBox2.Text = "127.0.0.1";
            //
            // label12
            //
            this.label12.Location = new System.Drawing.Point(424, 168);
            this.label12.Name = "label12";
            this.label12.Size = new System.Drawing.Size(80, 16);
            this.label12.TabIndex = 20;
            this.label12.Text = "目标主机名:";
            //
            // panel1
            //
            this.panel1.Controls.Add(this.button10);
            this.panel1.Controls.Add(this.checkedListBox1);
            this.panel1.Controls.Add(this.button11);
            this.panel1.Controls.Add(this.label5);
            this.panel1.Location = new System.Drawing.Point(440, 312);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(304, 128);
            this.panel1.TabIndex = 29;
            //
            // button10
            //
            this.button10.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(255)))));
            this.button10.Cursor = System.Windows.Forms.Cursors.Hand;
            this.button10.Font = new System.Drawing.Font("仿宋_GB2312", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.button10.ForeColor = System.Drawing.Color.Lime;
            this.button10.Location = new System.Drawing.Point(92, 18);
            this.button10.Name = "button10";
            this.button10.Size = new System.Drawing.Size(80, 23);
            this.button10.TabIndex = 23;
            this.button10.Text = "隐藏驱动器";
            this.button10.UseVisualStyleBackColor = false;
            this.button10.Click += new System.EventHandler(this.button10_Click);
            //
            // checkedListBox1
            //
            this.checkedListBox1.Cursor = System.Windows.Forms.Cursors.Hand;
            this.checkedListBox1.Location = new System.Drawing.Point(4, 42);
            this.checkedListBox1.Name = "checkedListBox1";
            this.checkedListBox1.Size = new System.Drawing.Size(296, 84);
            this.checkedListBox1.TabIndex = 22;
            //
            // button11
            //
            this.button11.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(255)))));
            this.button11.Cursor = System.Windows.Forms.Cursors.Hand;
            this.button11.Font = new System.Drawing.Font("仿宋_GB2312", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.button11.ForeColor = System.Drawing.Color.Lime;
            this.button11.Location = new System.Drawing.Point(12, 18);
            this.button11.Name = "button11";
            this.button11.Size = new System.Drawing.Size(80, 23);
            this.button11.TabIndex = 21;
            this.button11.Text = "取消隐藏";
            this.button11.UseVisualStyleBackColor = false;
            this.button11.Click += new System.EventHandler(this.button11_Click);
            //
            // label5
            //
            this.label5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(255)))));
            this.label5.Cursor = System.Windows.Forms.Cursors.Hand;
            this.label5.Font = new System.Drawing.Font("仿宋_GB2312", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.label5.ForeColor = System.Drawing.Color.Lime;
            this.label5.Location = new System.Drawing.Point(12, 2);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(144, 16);
            this.label5.TabIndex = 20;
            this.label5.Text = "选择需要隐藏的驱动器:";
            //
            // Form1
            //
            this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
            this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(255)))));
            this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
            this.ClientSize = new System.Drawing.Size(800, 445);
            this.Controls.Add(this.panel1);
            this.Controls.Add(this.progressBar1);
            this.Controls.Add(this.richTextBox1);
            this.Controls.Add(this.button3);
            this.Controls.Add(this.numericUpDown2);
            this.Controls.Add(this.label6);
            this.Controls.Add(this.numericUpDown1);
            this.Controls.Add(this.label8);
            this.Controls.Add(this.textBox2);
            this.Controls.Add(this.label12);
            this.Controls.Add(this.label4);
            this.Controls.Add(this.button9);
            this.Controls.Add(this.textBox1);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.button8);
            this.Controls.Add(this.button7);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.listView1);
            this.Controls.Add(this.button6);
            this.Controls.Add(this.button5);
            this.Controls.Add(this.button4);
            this.Controls.Add(this.button2);
            this.Controls.Add(this.button1);
            this.Controls.Add(this.listBox1);
            this.Controls.Add(this.label7);
            this.Controls.Add(this.label9);
            this.Controls.Add(this.label10);
            this.Controls.Add(this.label11);
            this.Name = "Form1";
            this.Text = "小程序";
            this.Load += new System.EventHandler(this.Form1_Load);
            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
            this.panel1.ResumeLayout(false);
            this.ResumeLayout(false);
            this.PerformLayout();
  }
  #endregion
  /// <summary>
  /// 应用程序的主入口点。
  /// </summary>
  [STAThread]
  static void Main()
  {
   Application.Run(new Form1());
  }
  private int iClose = 0;
  private const int WM_QUERYENDSESSION = 0x0011;
  protected override void WndProc(ref Message SystemMessage)
  {
   switch(SystemMessage.Msg)
   {
    case WM_QUERYENDSESSION:
     SystemMessage.Result = (IntPtr)iClose;
     break;
    default:
     base.WndProc(ref SystemMessage);
     break;
   }
  }
  private void button1_Click(object sender, System.EventArgs e)
  {
   //获取系统服务
   this.listBox1.Items.Clear();
   //搜索计算机上的所有任务
   ServiceController []MyServices = ServiceController.GetServices();
   //将服务的名称添加到ListBox中
   for(int i=0;i<MyServices.Length;i++)
   {
    this.listBox1.Items.Add(MyServices.ServiceName);
   }
  }
  private void button2_Click(object sender, System.EventArgs e)
  {
   //获取制定服务类型
   string MyText = this.listBox1.Text;
   if(MyText.Length < 1)
   {
    MessageBox.Show("请获取系统服务后选择服务!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
    return;
   }
   try
   {
    System.ServiceProcess.ServiceController MyService = new System.ServiceProcess.ServiceController();
    MyService.ServiceName = MyText;
    switch((int)MyService.ServiceType)
    {
     case 4:
      MessageBox.Show(MyText+":用于需要自己的驱动程序的硬件设备的服务。","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
      break;
     case 2:
      MessageBox.Show(MyText+":文件系统驱动程序,也是“内核”(Kernel)设备驱动程序。","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
      break;
     case 256:
      MessageBox.Show(MyText+":可与桌面通讯的服务。","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
      break;
     case 1:
      MessageBox.Show(MyText+":“内核”(Kernel) 设备驱动程序,如硬盘或其他低级别硬件设备驱动程序。","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
      break;
     case 8:
      MessageBox.Show(MyText+":文件系统驱动程序,用于在启动时确定系统中存在的文件系统。","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
      break;
     case 16:
      MessageBox.Show(MyText+":Win32 程序,可由“服务控制器”启动,并遵守服务控制协议。此类 Win32 服务单独运行在一个进程中。","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
      break;
     case 32:
      MessageBox.Show(MyText+":Win32 服务,可与其他 Win32 服务共享进程。","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
      break;
    }
   }
   catch(Exception Err)
   {
    MessageBox.Show("启动服务发生错误:"+Err.Message,"信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
   }
  }
  private void button4_Click(object sender, System.EventArgs e)
  {
   Application.Exit();
  }
  private void button5_Click(object sender, System.EventArgs e)
  {
   //获取当前进程项(除系统进程)ProcessModule
   this.listView1.Items.Clear();
   Process[] MyProcesses=Process.GetProcesses();
   int i=0;
   foreach(Process MyProcess in MyProcesses)
   {//枚举系统进程
    if(MyProcess.MainWindowTitle.Length>1)
    {//显示带窗口的应用程序
     string Title=MyProcess.MainWindowTitle;     
     string []SubItems={MyProcess.ProcessName,Title};
     ListViewItem Item=new ListViewItem(SubItems);
     this.listView1.Items.Insert(i++,Item);
    }
   }
  }
  private void Form1_Load(object sender, System.EventArgs e)
  {
  button5_Click(null,null);
   //搜索系统驱动器
   string[] MyDrivers=System.IO.Directory.GetLogicalDrives();
   this.checkedListBox1.Items.AddRange(MyDrivers);
  
  }
  private void button6_Click(object sender, System.EventArgs e)
  {
   //终止选中的程序
   ListViewItem Item = this.listView1.SelectedItems[0];
   string ProcessName = Item.Text;
   string Title = Item.SubItems[1].Text;
   if(MessageBox.Show("是否确认要关闭应用程序:"+Title+"?","信息提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question)==DialogResult.No)
   {
    return;
   }
   //取得制定进程
   Process[] MyProcess = Process.GetProcessesByName(ProcessName);
   MyProcess[0].EnableRaisingEvents = true;
   //添加进程退出事件代理
   MyProcess[0].Exited+=new EventHandler(button5_Click);
   //如果进程没有关闭
   if(!MyProcess[0].HasExited)
   {
    //如果关闭进程主窗口失败
    if(!MyProcess[0].CloseMainWindow())
    {
     if(MessageBox.Show("不能关闭应用程序窗口,需要继续终止进程吗?","信息提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question)==DialogResult.Yes)
     {
      try
      {
       //关闭进程
       MyProcess[0].Kill();
      }
      catch(Exception)
      {
       MessageBox.Show("不能终止进程","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
      }
     }
    }
   }
   else
   {
    MessageBox.Show("进程已经关闭!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
   }
  }

  private void button7_Click(object sender, System.EventArgs e)
  {
   //禁止关闭操作系统
   this.iClose = 0;
   MessageBox.Show("请选择“开始\\关闭计算机”菜单测试一下效果!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
  }
  private void button8_Click(object sender, System.EventArgs e)
  {
   //允许关闭操作系统
   this.iClose = 1;
   MessageBox.Show("请选择“开始\\关闭计算机”菜单测试一下效果!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
  }
  private void button3_Click(object sender, System.EventArgs e)
  {
   
  }

  private void button9_Click(object sender, System.EventArgs e)
  {
   //设置自启动程序
   if(this.textBox1.Text.Length<1)
   {
    MessageBox.Show("请首先浏览程序文件选择一个执行程序!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
    return;
   }
   try
   {
    string FileName=this.textBox1.Text;
    string ShortFileName=FileName.Substring(FileName.LastIndexOf("[url=file://\\]\\")+1[/url]);
    //打开子键节点
    RegistryKey MyReg=Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",true);
    if(MyReg==null)
    {//如果子键节点不存在,则创建之
     MyReg=Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
    }
    //在注册表中设置自启动程序
    MyReg.SetValue(ShortFileName,FileName);
    MessageBox.Show("设置自启动程序操作成功!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
   }
   catch(Exception)
   {
    MessageBox.Show("写注册表操作发生错误!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
   }
  }


  private void button3_Click_1(object sender, System.EventArgs e)
  {
   //扫描端口
   int iStart=(int)this.numericUpDown1.Value;
   int iEnd=(int)this.numericUpDown2.Value;
   try
   {
    this.progressBar1.Minimum=iStart;
    this.progressBar1.Maximum=iEnd;
    this.richTextBox1.Text="程序开始扫描端口:\n";
    this.richTextBox1.Update();
    for(int i=iStart ;i<iEnd;i++)
    {
     this.progressBar1.Value=i;
     TcpClient MyTCP=null;      
     try
     {
      MyTCP = new TcpClient(this.textBox1.Text,i);
      this.richTextBox1.Text+="端口 " + i.ToString() + " 开放!\n";
      this.richTextBox1.Update();
     }   
     catch
     {
     }   
    }
    this.richTextBox1.Text+="扫描端口结束!\n";   
   }
   catch(Exception Err)
   {
    MessageBox.Show("扫描端口操作发生错误,错误信息是:"+Err.Message,"信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
   }
  }
  private void button10_Click(object sender, System.EventArgs e)
  {
   //隐藏驱动器
   int iData=0;
   for(int i=0;i<this.checkedListBox1.CheckedItems.Count;i++)
   {
    string StrPath=this.checkedListBox1.CheckedItems.ToString();
    string DriverLetter=StrPath.Substring(0,1);
    switch(DriverLetter)
    {
     case "A":
      iData+=1;      
      break;
     case "B":
      iData+=1*2;      
      break;
     case "C":
      iData+=1*2*2;      
      break;
     case "D":
      iData+=1*2*2*2;      
      break;
     case "E":
      iData+=1*2*2*2*2;      
      break;
     case "F":
      iData+=1*2*2*2*2*2;      
      break;
     case "G":
      iData+=1*2*2*2*2*2*2;      
      break;
     case "H":
      iData+=1*2*2*2*2*2*2*2;      
      break;
     case "I":
      iData+=1*2*2*2*2*2*2*2*2;      
      break;
     case "J":
      iData+=1*2*2*2*2*2*2*2*2*2;      
      break;
     case "K":
      iData+=1*2*2*2*2*2*2*2*2*2*2;      
      break;
     case "L":
      iData+=1*2*2*2*2*2*2*2*2*2*2*2;      
      break;
     case "M":
      iData+=1*2*2*2*2*2*2*2*2*2*2*2*2;      
      break;
     case "N":
      iData+=1*2*2*2*2*2*2*2*2*2*2*2*2*2;      
      break;
     case "O":
      iData+=1*2*2*2*2*2*2*2*2*2*2*2*2*2*2;      
      break;
     case "P":
      iData+=1*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2;      
      break;
     case "Q":
      iData+=1*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2;      
      break;
     case "R":
      iData+=1*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2;      
      break;
     case "S":
      iData+=1*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2;      
      break;
     case "T":
      iData+=1*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2;      
      break;
     case "U":
      iData+=1*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2;      
      break;
     case "V":
      iData+=1*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2;      
      break;
     case "W":
      iData+=1*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2;      
      break;
     case "X":
      iData+=1*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2;      
      break;
     case "Y":
      iData+=1*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2;      
      break;
     case "Z":
      iData+=1*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2;      
      break;
     default:
      break;
    }   
   }
   try
   {
    RegistryKey MyReg=Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer");
    MyReg.SetValue("NoDrives",iData);
    MyReg.Close();
    MessageBox.Show("隐藏驱动器操作成功,注销计算机即可生效!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);

   }
   catch(Exception Err)
   {
    MessageBox.Show("隐藏驱动器发生错误:"+Err.Message,"信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
   }  
  }
  private void button11_Click(object sender, System.EventArgs e)
  {
   //取消隐藏驱动器
   try
   {
    RegistryKey MyReg=Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",true);
    MyReg.DeleteValue("NoDrives");
    MyReg.Close();
    MessageBox.Show("取消隐藏驱动器操作成功,注销计算机即可生效!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
   }
   catch(Exception Err)
   {
    MessageBox.Show("隐藏驱动器发生错误:"+Err.Message,"信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
   }
  }

}
}

TOP

着东西是干什么用滴啊~~~~~~~~~~~
给我说下性吗

Processed in 0.201202 second(s), 6 queries, Gzip enabled