By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,892 Members | 1,387 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,892 IT Pros & Developers. It's quick & easy.

How to check that registry key exists

P: n/a
hello, I want to check to see if a certain registry key exists on the registry. What's the easiest way to do this. Here is what I am currently doing.
private string registryKey = @"HKEY_LOCAL_MACHINE\Software\Techtracker"
if(registryKey.Equals(Registry.Localmachine.Create Key("Software").CreateKey("Techtracker").Name)

MessageBox.Show("Registry Key Exists")

els

MessageBox.Show("Registry Key doesn't Exists")
I also tried using registryKey.Equals(Registry.Localmachine.OpenKey(" Software").OpenKey("Techtracker").Name), but this gives me an error. Any ideas or feed on this will be greatly appreciated.
Nov 15 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Microsoft.Win32.RegistryKey subKey =
Microsoft.Win32.Registry.LocalMachine.OpenSubKey(S oftware\\TechTracker);

If (subKey != null)

{

MessageBox.Show("Registry Key exists");

}

else

{

MessageBox.Show("Registry Key does not exist");

}

Dale
"Ed P." <an*******@discussions.microsoft.com> wrote in message
news:0E**********************************@microsof t.com...
hello, I want to check to see if a certain registry key exists on the registry. What's the easiest way to do this. Here is what I am currently
doing. private string registryKey = @"HKEY_LOCAL_MACHINE\Software\Techtracker";
if(registryKey.Equals(Registry.Localmachine.Create Key("Software").CreateKey(
"Techtracker").Name)) {
MessageBox.Show("Registry Key Exists");
}
else
{
MessageBox.Show("Registry Key doesn't Exists");
}

I also tried using

registryKey.Equals(Registry.Localmachine.OpenKey(" Software").OpenKey("Techtr
acker").Name), but this gives me an error. Any ideas or feed on this will
be greatly appreciated.
Nov 15 '05 #2

P: n/a
Thanks dale, this seems to do the trick for what I was looking for!
Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.