using System;
using System.Collections; //加此引用
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace systeminfo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//取出所有环境变量
IDictionary vars = Environment.GetEnvironmentVariables();
foreach (DictionaryEntry de in vars)
{
textBox1.Text += de.Key + "=" + de.Value+"/r/n/r/n";
comboBox1.Items.Add(de.Key);
}
}
private void button2_Click(object sender, EventArgs e)
{
//读取指定环境名称的值
textBox2.Text =Environment.GetEnvironmentVariable(comboBox1.Text);
}
private void button3_Click(object sender, EventArgs e)
{
//将嵌入到指定字符串中的每个环境变量的名称替换为该变量的值的等效字符串,然后返回结果字符串。
textBox4.Text = Environment.ExpandEnvironmentVariables(textBox3.Text);
}
}
}