Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/274.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 防止环境变量的扩展_C#_.net_Environment Variables - Fatal编程技术网

C# 防止环境变量的扩展

C# 防止环境变量的扩展,c#,.net,environment-variables,C#,.net,Environment Variables,我目前正在开发一个应用程序,旨在成为Windows环境变量编辑器的改进版 我使用了System.Environment.GetEnvironmentVariables()和Registry来获取它们。但是,这两种方法都会将文本扩展到%之间,因此我在程序中获得的不是实例%systemroot%/system32/而是C:/Windows/system32/ 有没有办法防止这些项目的扩展?当您从注册表获取环境变量时-您需要使用一个特殊的标志:RegistryValueOptions.DoNotExp

我目前正在开发一个应用程序,旨在成为Windows环境变量编辑器的改进版

我使用了System.Environment.GetEnvironmentVariables()Registry来获取它们。但是,这两种方法都会将文本扩展到%之间,因此我在程序中获得的不是实例%systemroot%/system32/而是C:/Windows/system32/


有没有办法防止这些项目的扩展?

当您从注册表获取环境变量时-您需要使用一个特殊的标志:
RegistryValueOptions.DoNotExpandEnvironmentNames
当您从注册表获取环境变量时-您需要使用一个特殊的标志:
RegistryValueOptions.DoNotExpandEnvironmentNames