RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: .NET
Expertise: Beginner
Oct 24, 2006

Retrieving PC or System Information

To retrieve PC or System information (things like the operating system, domain name, logical drives, IP address, or environment variables), use the System class and the Environment class. List of name space used in the project

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using Microsoft.Win32;
using System.Collections;

private void Form1_Load(object sender, EventArgs e)

// There are about 5 labels  in the form

label1.Text = Environment.SystemDirectory;

label2.Text = Environment.MachineName;

label3.Text = Environment.CurrentDirectory;

label5.Text = Environment.OSVersion.ToString();

IDictionary environmentVariables = Environment.GetEnvironmentVariables();

string str2 = "";

string str3 = "";

foreach (DictionaryEntry de in environmentVariables)

str2 = de.Key.ToString();

str3 = str3 + str2 + " , ";

label5.Text = str3; 

Jayender Sivaraman
Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date