6

Is there any chance to open registry key using full registry path like:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon?

I know that I can open that node using:

RegistryKey.OpenBaseKey(RegistryHive.LocalMachine).OpenSubKey("Software\Microsoft\Windows NT\CurrentVersion\Winlogon")

But I would like to do it easier... In my application user can put registry key as a string and my application have to do somthing with it. Now I have to check what is on the begining and conditionally select suitable RegistryHieve. Isn't there any better and easier way for that?

2
  • To open , there is no API where you can directly pass the complete string but if your need is to read/write a value of any key then you can do that using Registry class (msdn.microsoft.com/en-us/library/…) Commented Oct 26, 2013 at 10:21
  • Hard to see what is wrong with String.StartsWith(), given the few number of hive names. Commented Oct 26, 2013 at 11:16

1 Answer 1

4

You just have to write a function that parses the registry path. Split the path at the first separator and compare the part before the first separator against the known root keys. Then open the key using the code in your question.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.