Test for Registry Key/Value

N

Nicholas Paldino [.NET/C# MVP]

Yogi_Bear_79,

You can use the RegistryKey class in the Microsoft.Win32 namespace. You
can call the GetValue method, which will return null if the value doesn't
exist. To check to see if a key exists, you can call the OpenSubKey method,
which will also return null if it doesn't exist.

Hope this helps.
 
Y

Yogi_Bear_79

I've been trying variations on that concept before and after my original
question with no luck. Can you give me a quick "aircode" example?

using (RegistryKey Key = Registry.CurrentUser)

{

if (Key.OpenSubKey(sKey)= null)

{

}

}

Nicholas Paldino said:
Yogi_Bear_79,

You can use the RegistryKey class in the Microsoft.Win32 namespace. You
can call the GetValue method, which will return null if the value doesn't
exist. To check to see if a key exists, you can call the OpenSubKey method,
which will also return null if it doesn't exist.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Yogi_Bear_79 said:
How do you test to see if a Registry Key & a Value exsist?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Does Registry Value/Key Exsist? 3
Registry tutorial 2
b-tree 11
Bug in RegistryKey.SetValue 2
System.Data.InvalidConstraintException was unhandled 0
Registery help 1
Excel Excel help please 4
sortedDictionary.Item ? 3

Top