Registry.GetValue自动扩展环境变量 - 什么办法避免? [英] Registry.GetValue automatically expands enviroment variables - any way to avoid that?

查看:156
本文介绍了Registry.GetValue自动扩展环境变量 - 什么办法避免?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用 Registry.GetValue(键,名称为null),而不是:

C:\Windows\system32

我想获取原始注册表项:

I would like to retrieve the raw registry entry:

%SystemRoot%\system32

这是可能的下用WinAPI的,但我不明白的方式来做到这一点与.NET。

This is possible in C with WinAPI, but I don't see a way to do that with .NET.

推荐答案

您需要通过它 RegistryValueOptions.DoNotExpandEnvironmentNames 。例如:

var key = @"SOFTWARE\Classes\.library-ms\ShellNew";
var name = "IconPath";

var regval = Registry.LocalMachine.OpenSubKey(key).GetValue(name, "",
RegistryValueOptions.DoNotExpandEnvironmentNames);

Console.WriteLine(regval);

输出为: %SYSTEMROOT%\ SYSTEM32 \ imageres.dll,-1001

output is: %SystemRoot%\System32\imageres.dll,-1001

这篇关于Registry.GetValue自动扩展环境变量 - 什么办法避免?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆