How to check that registry key exists

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.CreateKey("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.
 
Microsoft.Win32.RegistryKey subKey =
Microsoft.Win32.Registry.LocalMachine.OpenSubKey(Software\\TechTracker);

If (subKey != null)

{

MessageBox.Show("Registry Key exists");

}

else

{

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

}

Dale


Ed P. said:
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.CreateKey("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.
 
Back
Top