-
Registry Reading
Keep getting an error on this code:
Code:
RegistryKey rKey = Registry.LocalMachine;
rKey.OpenSubKey(@"\SOFTWARE\Blizzard Entertainment\World of Warcraft", true);
try
{
return rKey.GetValue("InstallPath").ToString();
}
catch (NullReferenceException)
{
return null;
}
I KNOW for certain that a key exists in this location, so the key not existing is out of the question.
Unsure what the issue could be.
ETA: Obviously the error no longer appears due to the catch, but that should have been obvious.
-
Re: Registry Reading
Try the following way :
RegistryKey rkey;
rkey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Blizzard Entertainment\World of Warcraft",true);
also , try Convert.ToString function in the return snippet
-
Re: Registry Reading
That's because you set rKey = HKLM key, and certainly the HKLM doesn't contain the subkey "InstallPath", so when you try to call ToString on rKey.GetValue("InstallPath"), you get null exeception. Pirate's code should work.
-
Re: Registry Reading
Thanks guys.
I must not have been following the tutorial properly :)
All working.