|
-
Jan 9th, 2009, 10:05 AM
#1
Thread Starter
Member
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.
-
Jan 9th, 2009, 01:29 PM
#2
Sleep mode
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
Last edited by Pirate; Jan 9th, 2009 at 01:32 PM.
-
Jan 9th, 2009, 03:50 PM
#3
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.
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Jan 10th, 2009, 02:09 AM
#4
Thread Starter
Member
Re: Registry Reading
Thanks guys.
I must not have been following the tutorial properly 
All working.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|