开发者

Getting a specific branch and all its values in the registry

开发者 https://www.devze.com 2023-02-22 21:07 出处:网络
I want to be able to get all the value pairs under a location in the registry, like: RegistryKey printerkey =

I want to be able to get all the value pairs under a location in the registry, like:

 RegistryKey printerkey =
                settingsRegKey.OpenSubKey("\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Print\\Printers\\Dev开发者_Go百科Modes2\\Settings");

I can select Registry.LocalSystem, etc, but how do I then get to a specific branch (like above)?

Thanks


Dictionary<string, object> keyValuePairs;
using (var settingsRegKey = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows NT\\CurrentVersion\\Print\\Printers\\DevModes2\\Settings"))
{
       var valueNames = settingsRegKey.GetValueNames();
       keyValuePairs = valueNames.ToDictionary(name => name, settingsRegKey.GetValue);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消