System.Evironment类里面有几个属性可以得到一部分用户信息。另外的可以调用win32 api获得, 再具体的就不清楚了,你可以查一下msdn

解决方案 »

  1.   

    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;
    using System.IO;
    using System.Diagnostics;
    using System.Runtime.Serialization;
    using System.Runtime.InteropServices;
    namespace 原代码管理器
    {
    /// <summary>
    /// Form1 的摘要说明。
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
    private System.Windows.Forms.TabControl tabControl1;
    private System.Windows.Forms.TabPage tabPage1;
    private System.Windows.Forms.TabPage tabPage2;
    private System.Windows.Forms.TabPage tabPage3;
    private System.Windows.Forms.MainMenu mainMenu1;
    private System.Windows.Forms.MenuItem menuItem1;
    private System.Windows.Forms.MenuItem menuItem2;
    private System.Windows.Forms.MenuItem menuItem3;
    private System.Windows.Forms.MenuItem menuItem4;
    private System.Windows.Forms.MenuItem menuItem5;
    private System.Windows.Forms.MenuItem menuItem6;
    private System.Windows.Forms.MenuItem menuItem7;
    private System.Windows.Forms.MenuItem menuItem8;
    private System.Windows.Forms.MenuItem menuItem10;
    private System.Windows.Forms.MenuItem menuItem11;
    private System.Windows.Forms.MenuItem menuItem12;
    private System.Windows.Forms.RichTextBox richTextBox1;
    private System.Windows.Forms.MenuItem menuItem14;
    private System.Windows.Forms.MenuItem menuItem15;
    private System.Windows.Forms.Label label1;
    private System.Windows.Forms.ComboBox comboBox1;
    private System.Windows.Forms.Button button1;
    private System.Windows.Forms.Button button2;
    private System.Windows.Forms.ListBox listBox1;
    private System.Windows.Forms.Label label2;
    private System.Windows.Forms.TextBox textBox1;
    private System.Windows.Forms.TextBox textBox2;
    private System.Windows.Forms.ListBox listBox2;
    private System.Windows.Forms.Button button3;
    private System.Windows.Forms.SaveFileDialog saveFileDialog1;
    private System.Windows.Forms.OpenFileDialog openFileDialog1;
    private System.Windows.Forms.FontDialog fontDialog1;
    private System.Windows.Forms.ColorDialog colorDialog1;
    private System.Windows.Forms.ListView listView1;
    private System.Windows.Forms.Label label3;
    private System.Windows.Forms.Button button5;
    private System.Windows.Forms.Label label4;
    private System.Windows.Forms.DateTimePicker dateTimePicker1;
    private System.Windows.Forms.Timer timer1;
    private System.Windows.Forms.TextBox textBox4;
    private System.Windows.Forms.ComboBox comboBox2;
    private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
    private System.Data.SqlClient.SqlCommand sqlInsertCommand1;
    private System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
    private System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
    private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
    private System.Data.SqlClient.SqlConnection sqlConnection1;
    private System.Data.SqlClient.SqlCommand sqlCommand1;
    private System.ComponentModel.IContainer components; 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()
    {
    this.components = new System.ComponentModel.Container();
    this.tabControl1 = new System.Windows.Forms.TabControl();
    this.tabPage1 = new System.Windows.Forms.TabPage();
    this.textBox1 = new System.Windows.Forms.TextBox();
    this.label2 = new System.Windows.Forms.Label();
    this.listBox1 = new System.Windows.Forms.ListBox();
    this.button2 = new System.Windows.Forms.Button();
    this.button1 = new System.Windows.Forms.Button();
    this.comboBox1 = new System.Windows.Forms.ComboBox();
    this.label1 = new System.Windows.Forms.Label();
    this.richTextBox1 = new System.Windows.Forms.RichTextBox();
    this.tabPage2 = new System.Windows.Forms.TabPage();
    this.comboBox2 = new System.Windows.Forms.ComboBox();
    this.button3 = new System.Windows.Forms.Button();
    this.listBox2 = new System.Windows.Forms.ListBox();
    this.textBox2 = new System.Windows.Forms.TextBox();
    this.tabPage3 = new System.Windows.Forms.TabPage();
    this.textBox4 = new System.Windows.Forms.TextBox();
    this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
    this.label4 = new System.Windows.Forms.Label();
    this.button5 = new System.Windows.Forms.Button();
    this.label3 = new System.Windows.Forms.Label();
    this.listView1 = new System.Windows.Forms.ListView();
    this.mainMenu1 = new System.Windows.Forms.MainMenu();
    this.menuItem1 = new System.Windows.Forms.MenuItem();
    this.menuItem4 = new System.Windows.Forms.MenuItem();
    this.menuItem5 = new System.Windows.Forms.MenuItem();
    this.menuItem14 = new System.Windows.Forms.MenuItem();
    this.menuItem15 = new System.Windows.Forms.MenuItem();
    this.menuItem6 = new System.Windows.Forms.MenuItem();
    this.menuItem7 = new System.Windows.Forms.MenuItem();
    this.menuItem2 = new System.Windows.Forms.MenuItem();
    this.menuItem8 = new System.Windows.Forms.MenuItem();
    this.menuItem10 = new System.Windows.Forms.MenuItem();
    this.menuItem11 = new System.Windows.Forms.MenuItem();
    this.menuItem3 = new System.Windows.Forms.MenuItem();
    this.menuItem12 = new System.Windows.Forms.MenuItem();
    this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
    this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
    this.fontDialog1 = new System.Windows.Forms.FontDialog();
    this.colorDialog1 = new System.Windows.Forms.ColorDialog();
    this.timer1 = new System.Windows.Forms.Timer(this.components);
    this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
    this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
    this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
    this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
    this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
    this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
    this.sqlCommand1 = new System.Data.SqlClient.SqlCommand();
    this.tabControl1.SuspendLayout();
    this.tabPage1.SuspendLayout();
    this.tabPage2.SuspendLayout();
    this.tabPage3.SuspendLayout();
    this.SuspendLayout();
    // 
    // tabControl1
    // 
    this.tabControl1.Controls.Add(this.tabPage1);
    this.tabControl1.Controls.Add(this.tabPage2);
    this.tabControl1.Controls.Add(this.tabPage3);
    this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
    this.tabControl1.Location = new System.Drawing.Point(0, 0);
    this.tabControl1.Name = "tabControl1";
    this.tabControl1.SelectedIndex = 0;
    this.tabControl1.Size = new System.Drawing.Size(800, 545);
    this.tabControl1.TabIndex = 0;
    // 
    // tabPage1
    // 
    this.tabPage1.Controls.Add(this.textBox1);
    this.tabPage1.Controls.Add(this.label2);
    this.tabPage1.Controls.Add(this.listBox1);
    this.tabPage1.Controls.Add(this.button2);
    this.tabPage1.Controls.Add(this.button1);
    this.tabPage1.Controls.Add(this.comboBox1);
    this.tabPage1.Controls.Add(this.label1);
    this.tabPage1.Controls.Add(this.richTextBox1);
    this.tabPage1.Location = new System.Drawing.Point(4, 21);
    this.tabPage1.Name = "tabPage1";
    this.tabPage1.Size = new System.Drawing.Size(792, 520);
    this.tabPage1.TabIndex = 0;
    this.tabPage1.Text = "原码编辑窗体";
      

  2.   

    // 
    // textBox1
    // 
    this.textBox1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
    this.textBox1.Location = new System.Drawing.Point(336, 8);
    this.textBox1.Name = "textBox1";
    this.textBox1.Size = new System.Drawing.Size(384, 23);
    this.textBox1.TabIndex = 7;
    this.textBox1.Text = "";
    // 
    // label2
    // 
    this.label2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
    this.label2.Location = new System.Drawing.Point(208, 8);
    this.label2.Name = "label2";
    this.label2.Size = new System.Drawing.Size(112, 32);
    this.label2.TabIndex = 6;
    this.label2.Text = "请输入标题:";
    // 
    // listBox1
    // 
    this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
    | System.Windows.Forms.AnchorStyles.Left)));
    this.listBox1.ItemHeight = 12;
    this.listBox1.Location = new System.Drawing.Point(8, 88);
    this.listBox1.MultiColumn = true;
    this.listBox1.Name = "listBox1";
    this.listBox1.ScrollAlwaysVisible = true;
    this.listBox1.Size = new System.Drawing.Size(152, 316);
    this.listBox1.TabIndex = 5;
    // 
    // button2
    // 
    this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    this.button2.Location = new System.Drawing.Point(8, 467);
    this.button2.Name = "button2";
    this.button2.Size = new System.Drawing.Size(152, 48);
    this.button2.TabIndex = 4;
    this.button2.Text = "退出程序";
    // 
    // button1
    // 
    this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    this.button1.Location = new System.Drawing.Point(8, 411);
    this.button1.Name = "button1";
    this.button1.Size = new System.Drawing.Size(152, 48);
    this.button1.TabIndex = 3;
    this.button1.Text = "保存原码";
    this.button1.Click += new System.EventHandler
      

  3.   

    // 
    // comboBox1
    // 
    this.comboBox1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
    this.comboBox1.Location = new System.Drawing.Point(8, 56);
    this.comboBox1.Name = "comboBox1";
    this.comboBox1.Size = new System.Drawing.Size(152, 24);
    this.comboBox1.TabIndex = 2;
    this.comboBox1.Text = "请选择...";
    // 
    // label1
    // 
    this.label1.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
    this.label1.Location = new System.Drawing.Point(8, 24);
    this.label1.Name = "label1";
    this.label1.Size = new System.Drawing.Size(152, 24);
    this.label1.TabIndex = 1;
    this.label1.Text = "选择存放的语言";
    // 
    // richTextBox1
    // 
    this.richTextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
    | System.Windows.Forms.AnchorStyles.Left) 
    | System.Windows.Forms.AnchorStyles.Right)));
    this.richTextBox1.Location = new System.Drawing.Point(168, 48);
    this.richTextBox1.Name = "richTextBox1";
    this.richTextBox1.Size = new System.Drawing.Size(616, 467);
    this.richTextBox1.TabIndex = 0;
    this.richTextBox1.Text = "";
    // 
    // tabPage2
    // 
    this.tabPage2.Controls.Add(this.comboBox2);
    this.tabPage2.Controls.Add(this.button3);
    this.tabPage2.Controls.Add(this.listBox2);
    this.tabPage2.Controls.Add(this.textBox2);
    this.tabPage2.Location = new System.Drawing.Point(4, 21);
    this.tabPage2.Name = "tabPage2";
    this.tabPage2.Size = new System.Drawing.Size(792, 520);
    this.tabPage2.TabIndex = 1;
    this.tabPage2.Text = "代码显示窗体";
    // 
    // comboBox2
    // 
    this.comboBox2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
    this.comboBox2.Location = new System.Drawing.Point(8, 8);
    this.comboBox2.Name = "comboBox2";
    this.comboBox2.Size = new System.Drawing.Size(144, 24);
    this.comboBox2.TabIndex = 4;
    this.comboBox2.Text = "请选择...";
    // 
    // button3
    // 
    this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    this.button3.Font = new System.Drawing.Font("隶书", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
    this.button3.Location = new System.Drawing.Point(8, 451);
    this.button3.Name = "button3";
    this.button3.Size = new System.Drawing.Size(144, 64);
    this.button3.TabIndex = 3;
    this.button3.Text = "查询";
    // 
    // listBox2
    // 
    this.listBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
    | System.Windows.Forms.AnchorStyles.Left)));
    this.listBox2.ItemHeight = 12;
    this.listBox2.Location = new System.Drawing.Point(8, 48);
    this.listBox2.MultiColumn = true;
    this.listBox2.Name = "listBox2";
    this.listBox2.ScrollAlwaysVisible = true;
    this.listBox2.Size = new System.Drawing.Size(144, 388);
    this.listBox2.TabIndex = 2;
    // 
    // textBox2
    // 
    this.textBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
    | System.Windows.Forms.AnchorStyles.Left) 
    | System.Windows.Forms.AnchorStyles.Right)));
    this.textBox2.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
    this.textBox2.Location = new System.Drawing.Point(160, 0);
    this.textBox2.Multiline = true;
    this.textBox2.Name = "textBox2";
    this.textBox2.ScrollBars = System.Windows.Forms.ScrollBars.Both;
    this.textBox2.Size = new System.Drawing.Size(632, 515);
    this.textBox2.TabIndex = 0;
    this.textBox2.Text = "";
    // 
    // tabPage3
    // 
    this.tabPage3.Controls.Add(this.textBox4);
    this.tabPage3.Controls.Add(this.dateTimePicker1);
    this.tabPage3.Controls.Add(this.label4);
    this.tabPage3.Controls.Add(this.button5);
    this.tabPage3.Controls.Add(this.label3);
    this.tabPage3.Controls.Add(this.listView1);
    this.tabPage3.Location = new System.Drawing.Point(4, 21);
    this.tabPage3.Name = "tabPage3";
    this.tabPage3.Size = new System.Drawing.Size(792, 520);
    this.tabPage3.TabIndex = 2;
    this.tabPage3.Text = "版本信息";
    // 
    // textBox4
    // 
    this.textBox4.BackColor = System.Drawing.Color.White;
    this.textBox4.Enabled = false;
    this.textBox4.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
    this.textBox4.ForeColor = System.Drawing.Color.Brown;
    this.textBox4.Location = new System.Drawing.Point(160, 8);
    this.textBox4.Name = "textBox4";
    this.textBox4.Size = new System.Drawing.Size(208, 23);
    this.textBox4.TabIndex = 6;
    this.textBox4.Text = "";
    // 
    // dateTimePicker1
    // 
    this.dateTimePicker1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
    this.dateTimePicker1.Location = new System.Drawing.Point(8, 8);
    this.dateTimePicker1.Name = "dateTimePicker1";
    this.dateTimePicker1.Size = new System.Drawing.Size(144, 26);
    this.dateTimePicker1.TabIndex = 5;
    // 
    // label4
    // 
    this.label4.Font = new System.Drawing.Font("隶书", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
    this.label4.Location = new System.Drawing.Point(16, 424);
    this.label4.Name = "label4";
    this.label4.Size = new System.Drawing.Size(344, 88);
    this.label4.TabIndex = 4;
    // 
    // button5
    // 
    this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    this.button5.Font = new System.Drawing.Font("楷体_GB2312", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
    this.button5.Location = new System.Drawing.Point(616, 472);
    this.button5.Name = "button5";
    this.button5.Size = new System.Drawing.Size(144, 40);
    this.button5.TabIndex = 3;
    this.button5.Text = "退出";
    this.button5.Click += new System.EventHandler(this.button5_Click);