This article describes the method of C# to obtain the system information of the running platform. It can mainly realize C# to obtain the number of milliseconds passed by the system startup, the network domain name connected, the number of milliseconds passed by the system startup, etc., and there are related operations on the ListView control.
The specific implementation code is as follows:
using System; using ; using ; using ; using ; using ; namespace Obtain system environment and platform information { public class Form1 : { private button1; private button2; private listView1; private columnHeader1; private columnHeader2; private components = null; public Form1() { InitializeComponent(); } protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { (); } } ( disposing ); } #region Code generated by Windows Form Designer private void InitializeComponent() { this.button1 = new (); this.button2 = new (); this.listView1 = new (); this.columnHeader1 = new (); this.columnHeader2 = new (); (); // button1 this. = new (48, 224); this. = "button1"; this. = new (56, 32); this. = 4; this. = "Get"; this. += new (this.button1_Click); // button2 this. = new (184, 224); this. = "button2"; this. = new (56, 32); this. = 5; this. = "quit"; this. += new (this.button2_Click); // // listView1 this.(new [] { this.columnHeader1, this.columnHeader2}); this. = true; this. = new (16, 24); this. = "listView1"; this. = new (256, 184); this. = 6; this. = ; // columnHeader1 this. = "property"; this. = 100; // columnHeader2 this. = "value"; this. = 175; // Form1 = new (6, 14); = new (292, 273); (this.listView1); (this.button2); (this.button1); = "Form1"; = "Get system environment and platform information"; (false); } #endregion [STAThread] static void Main() { (new Form1()); } private void button2_Click(object sender, e) { // Close the current form (); } private void button1_Click(object sender, e) { (); // Clear items in ListView control ListViewItem listViewItem; try { // Add computer name listViewItem = new ListViewItem("Computer Name", 0); (); (listViewItem); // Add to the current platform name listViewItem = new ListViewItem("Current Platform Name", 0); (()); (listViewItem); // Add platform version number listViewItem = new ListViewItem("Platform Version Number", 0); (()); (listViewItem); // The network name connected to the system listViewItem = new ListViewItem("Connected network domain name", 0); (); (listViewItem); // System directory path listViewItem = new ListViewItem("Number of milliseconds passed by system startup", 0); ( ); (listViewItem); // Current system time listViewItem = new ListViewItem("System Current Time", 0); (()); (listViewItem); // The number of milliseconds elapsed after the system starts listViewItem = new ListViewItem("Number of milliseconds passed by system startup", 0); (()); (listViewItem); } catch(Exception exc) { (, "hint"); } } // To avoid lengthy code written, add the AddItem method public void AddItem(string sItem) { // Add item sItem to listView1 (sItem); } } }