OpenSubKey() 注册表项的“绝对路径”?
OpenSubKey() Registry key's “Absolute Path”?
使用需要注册表路径的 Microsoft.Win32.RegistryKey
C# 函数,如 OpenSubKey()
,使用像
这样的路径
@"SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp"
生成一个错误,指出 “需要绝对路径信息。”
创建所需绝对路径的语法是什么?
注册表有几个根项,所有子项都与其中一个相关。
In order to use the OpenSubKey method, you must have an instance of the RegistryKey method. To get an instance of RegistryKey, use one of the static members of the Registry class.
例如,如果您想要在 Regedit 中看到的密钥 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet
,则必须以 Registry.LocalMachine
.
开头
RegistryKey rk = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet");
... = rk.GetValue(...);
如果您已有密钥,yourkey.Name
是密钥的路径。
使用需要注册表路径的 Microsoft.Win32.RegistryKey
C# 函数,如 OpenSubKey()
,使用像
@"SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp"
生成一个错误,指出 “需要绝对路径信息。”
创建所需绝对路径的语法是什么?
注册表有几个根项,所有子项都与其中一个相关。
In order to use the OpenSubKey method, you must have an instance of the RegistryKey method. To get an instance of RegistryKey, use one of the static members of the Registry class.
例如,如果您想要在 Regedit 中看到的密钥 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet
,则必须以 Registry.LocalMachine
.
RegistryKey rk = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet");
... = rk.GetValue(...);
如果您已有密钥,yourkey.Name
是密钥的路径。