7,765
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
using Microsoft.Win32;
namespace EnvironmentTest
{
class Program
{
static void Main(string[] args)
{
IDictionary envir = Environment.GetEnvironmentVariables(EnvironmentVariableTarget.Machine);
ICollection col = envir.Values;
foreach (String str in col)
{
Console.WriteLine(str);
Console.Read();
}
//RegistryKey regLocalMachine = Registry.LocalMachine;
//RegistryKey regSYSTEM = regLocalMachine.OpenSubKey("SYSTEM", true);//打开HKEY_LOCAL_MACHINE下的SYSTEM
//RegistryKey regControlSet001 = regSYSTEM.OpenSubKey("ControlSet001", true);//打开ControlSet001
//RegistryKey regControl = regControlSet001.OpenSubKey("Control", true);//打开Control
//RegistryKey regManager = regControl.OpenSubKey("Session Manager", true);//打开Control
//RegistryKey regEnvironment = regManager.OpenSubKey("Environment", true);//打开MSSQLServer下的MSSQLServer
//Console.WriteLine(regEnvironment.GetValue("path").ToString());
//Console.Read();
}
}
}