C#使用System.Environment操作系统环境变量的中文API

来源:互联网 发布:java 发送tcp报文 编辑:程序博客网 时间:2024/05/29 15:33

静态类:System.Environment

说明:Environment类提供有关当前环境和平台的信息以及操作它们的方法。无法继承此类。使用 Environment类可检索信息,如命令行参数、退出代码、环境变量设置、调用堆栈的内容、自上次系统启动以来的时间,以及公共语言运行库的版本等。

属性:

摘要:获取该进程的命令行。public static string CommandLine { get; }摘要:获取和设置当前目录(即该进程从中启动的目录)的完全限定路径。public static string CurrentDirectory { get; set; }摘要:获取或设置进程的退出代码。public static int ExitCode { get; set; }摘要:获取一个值,该值指示是否公共语言运行库正在关闭或者当前的应用程序域正在卸载。public static bool HasShutdownStarted { get; }摘要:获取此本地计算机的 NetBIOS 名称。public static string MachineName { get; }摘要:获取为此环境定义的换行字符串。“\r\n”用于非 Unix 平台或“\n”用于 Unix 平台。public static string NewLine { get; }摘要:获取包含当前平台标识符和版本号的 System.OperatingSystem 对象。public static OperatingSystem OSVersion { get; }摘要:获取当前计算机上的处理器数。public static int ProcessorCount { get; }摘要:获取当前的堆栈跟踪信息。public static string StackTrace { get; }摘要:获取系统目录的完全限定路径。public static string SystemDirectory { get; }摘要:获取系统启动后经过的毫秒数。public static int TickCount { get; }摘要:获取与当前用户关联的网络域名。public static string UserDomainName { get; }摘要:获取一个值,用以指示当前进程是否在用户交互模式中运行。public static bool UserInteractive { get; }摘要:获取启动当前线程的人的用户名。public static string UserName { get; }摘要:获取一个System.Version对象,该对象描述公共语言运行库的主版本、次版本、内部版本和修订号。public static Version Version { get; }摘要:获取映射到进程上下文的物理内存量。public static long WorkingSet { get; }

方法:

摘要:终止此进程并为基础操作系统提供指定的退出代码。public static void Exit(int exitCode);摘要:将嵌入到指定字符串中的每个环境变量名称替换为该变量的值的等效字符串,然后返回结果字符串。public static string ExpandEnvironmentVariables(string name);摘要:终止进程但不执行任何活动 try-finally 块或终结器。public static void FailFast(string message);摘要:返回包含当前进程的命令行参数的字符串数组。public static string[] GetCommandLineArgs();摘要:从当前进程检索环境变量的值。public static string GetEnvironmentVariable(string variable);摘要:从当前进程或者从当前用户或本地计算机的 Windows 操作系统注册表项检索环境变量的值。public static string GetEnvironmentVariable(string variable, EnvironmentVariableTarget target);摘要:从当前进程检索所有环境变量名及其值。public static IDictionary GetEnvironmentVariables();摘要:从当前进程或者从当前用户或本地计算机的 Windows 操作系统注册表项检索所有环境变量名及其值。public static IDictionary GetEnvironmentVariables(EnvironmentVariableTarget target);摘要:获取指向由指定枚举标识的系统特殊文件夹的路径。public static string GetFolderPath(Environment.SpecialFolder folder);摘要:返回包含当前计算机中的逻辑驱动器名称的字符串数组。public static string[] GetLogicalDrives();摘要:创建、修改或删除当前进程中存储的环境变量。public static void SetEnvironmentVariable(string variable, string value);摘要:创建、修改或删除当前进程中或者为当前用户或本地计算机保留的 Windows 操作系统注册表项中存储的环境变量。public static void SetEnvironmentVariable(string variable, string value, EnvironmentVariableTarget target);
0 0
原创粉丝点击