.NET RegistryKey::OpenSubKey not working

Hello,

I want to retrieve some values in HKEY_LOCAL_MACHINE.

sk = lm->OpenSubKey(L"Software\\Microsoft\\WindowsNT");
returns nothing...

sk = lm->OpenSubKey(L"Software\\Microsoft");
returns valid information

There are no exceptions being raised.  The path exists in the registry.  I have read permissions to the key.  I have no idea what is wrong...  HeLp, please!  :)
RegistryKey ^lm;
RegistryKey ^sk;
	
lm = Registry::LocalMachine;
sk = lm->OpenSubKey(L"Software\\Microsoft\\WindowsNT");
 
if (sk) sk->Close();
if (lm) lm->Close();

Open in new window

mjgardneAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Fernando SotoConnect With a Mentor RetiredCommented:
Hi mjgardne;

The SubKey is incorrect. Change this:
sk = lm->OpenSubKey(L"Software\\Microsoft\\WindowsNT");
To this:
sk = lm->OpenSubKey(L"Software\\Microsoft\\Windows NT");
There is a space between the s in Windows and NT.

Fernando
0
 
mjgardneAuthor Commented:
Thanks, Fernando!  I think that I need to visit the eye doctor!  :)
0
 
Fernando SotoRetiredCommented:
Not a problem, glad I was able to help.  ;=)
0
All Courses

From novice to tech pro — start learning today.