最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

C#實(shí)現(xiàn)獲取運(yùn)行平臺系統(tǒng)信息的方法

 更新時(shí)間:2014年07月29日 09:53:11   投稿:shichen2014  
這篇文章主要介紹了C#實(shí)現(xiàn)獲取運(yùn)行平臺系統(tǒng)信息的方法,比較典型的C#應(yīng)用,需要的朋友可以參考下

本文實(shí)例講述了C#獲取運(yùn)行平臺系統(tǒng)信息的方法,主要可以實(shí)現(xiàn)C#獲取系統(tǒng)啟動經(jīng)過的毫秒數(shù),相連網(wǎng)絡(luò)域名,系統(tǒng)啟動經(jīng)過的毫秒數(shù)等,并有關(guān)于ListView控件的相關(guān)操作。

具體的實(shí)現(xiàn)代碼如下:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace 獲取系統(tǒng)環(huán)境和平臺信息
{
 public class Form1 : System.Windows.Forms.Form
 {
 private System.Windows.Forms.Button button1;
 private System.Windows.Forms.Button button2;
 private System.Windows.Forms.ListView listView1;
 private System.Windows.Forms.ColumnHeader columnHeader1;
 private System.Windows.Forms.ColumnHeader columnHeader2;
 private System.ComponentModel.Container components = null;
 public Form1()
 {
  InitializeComponent();
 }
 protected override void Dispose( bool disposing )
 {
  if( disposing )
  {
  if (components != null)
  {
   components.Dispose();
  }
  }
  base.Dispose( disposing );
 }
 #region Windows 窗體設(shè)計(jì)器生成的代碼
 private void InitializeComponent()
 {
  this.button1 = new System.Windows.Forms.Button();
  this.button2 = 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.SuspendLayout();
  // button1
  this.button1.Location = new System.Drawing.Point(48, 224);
  this.button1.Name = "button1";
  this.button1.Size = new System.Drawing.Size(56, 32);
  this.button1.TabIndex = 4;
  this.button1.Text = "獲取";
  this.button1.Click += new System.EventHandler(this.button1_Click);
  // button2
  this.button2.Location = new System.Drawing.Point(184, 224);
  this.button2.Name = "button2";
  this.button2.Size = new System.Drawing.Size(56, 32);
  this.button2.TabIndex = 5;
  this.button2.Text = "退出";
  this.button2.Click += new System.EventHandler(this.button2_Click);
  //
  // listView1
  this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
           this.columnHeader1,
           this.columnHeader2});
  this.listView1.GridLines = true;
  this.listView1.Location = new System.Drawing.Point(16, 24);
  this.listView1.Name = "listView1";
  this.listView1.Size = new System.Drawing.Size(256, 184);
  this.listView1.TabIndex = 6;
  this.listView1.View = System.Windows.Forms.View.Details;
  // columnHeader1
  this.columnHeader1.Text = "屬性";
  this.columnHeader1.Width = 100;
  // columnHeader2
  this.columnHeader2.Text = "值";
  this.columnHeader2.Width = 175;
  // Form1
  this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  this.ClientSize = new System.Drawing.Size(292, 273);
  this.Controls.Add(this.listView1);
  this.Controls.Add(this.button2);
  this.Controls.Add(this.button1);
  this.Name = "Form1";
  this.Text = "獲取系統(tǒng)環(huán)境和平臺信息";
  this.ResumeLayout(false);
 }
 #endregion
 [STAThread]
 static void Main()
 {
  Application.Run(new Form1());
 }
 private void button2_Click(object sender, System.EventArgs e)
 {
  // 關(guān)閉當(dāng)前窗體
  this.Close();
 }
 private void button1_Click(object sender, System.EventArgs e)
 {
  listView1.Items.Clear(); // 清除ListView控件中的項(xiàng)
  ListViewItem listViewItem;
  try
  {
  // 加入計(jì)算機(jī)名
  listViewItem = new ListViewItem("計(jì)算機(jī)名", 0);
  listViewItem.SubItems.Add(Environment.MachineName);
  listView1.Items.Add(listViewItem);
  // 加入當(dāng)前平臺名
  listViewItem = new ListViewItem("當(dāng)前平臺名", 0);
  listViewItem.SubItems.Add(Environment.OSVersion.Platform.ToString());
  listView1.Items.Add(listViewItem);
  // 加入平臺版本號
  listViewItem = new ListViewItem("平臺版本號", 0);
  listViewItem.SubItems.Add(Environment.OSVersion.Version.ToString());
  listView1.Items.Add(listViewItem);
  // 與系統(tǒng)相連的網(wǎng)絡(luò)名
  listViewItem = new ListViewItem("相連網(wǎng)絡(luò)域名", 0);
  listViewItem.SubItems.Add(Environment.UserDomainName);
  listView1.Items.Add(listViewItem);
  // 系統(tǒng)目錄路徑
  listViewItem = new ListViewItem("系統(tǒng)啟動經(jīng)過的毫秒數(shù)", 0);
  listViewItem.SubItems.Add(Environment.SystemDirectory );
  listView1.Items.Add(listViewItem);
  // 系統(tǒng)當(dāng)前時(shí)間
  listViewItem = new ListViewItem("系統(tǒng)當(dāng)前時(shí)間", 0);
  listViewItem.SubItems.Add(DateTime.Now.ToString());
  listView1.Items.Add(listViewItem);
  // 系統(tǒng)啟動后經(jīng)過的毫秒數(shù)
  listViewItem = new ListViewItem("系統(tǒng)啟動經(jīng)過的毫秒數(shù)", 0);
  listViewItem.SubItems.Add(Environment.TickCount.ToString());
  listView1.Items.Add(listViewItem);
  }
  catch(Exception exc)
  {
  MessageBox.Show(exc.Message, "提示");
  }
 }
 // 為避免編寫的代碼冗長,添加 AddItem 方法
 public void AddItem(string sItem)
 {
  // 添加項(xiàng) sItem 到 listView1 中
  listView1.Items.Add(sItem);
 }
 }
}

相關(guān)文章

最新評論

康定县| 寿光市| 河东区| 峨眉山市| 轮台县| 罗甸县| 南开区| 呼玛县| 海盐县| 巴楚县| 南汇区| 建宁县| 沭阳县| 临朐县| 汉沽区| 庆阳市| 鱼台县| 红安县| 志丹县| 阿鲁科尔沁旗| 杭州市| 蒲城县| 西宁市| 六枝特区| 栾川县| 舟山市| 隆林| 务川| 两当县| 新津县| 白山市| 桂阳县| 宿迁市| 东方市| 龙游县| 佛冈县| 大洼县| 丹江口市| 新蔡县| 丹东市| 昭通市|