Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

.NET RegistryKey::OpenSubKey not working

Posted on 2009-04-05
3
Medium Priority
?
539 Views
Last Modified: 2013-12-17
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

0
Comment
Question by:mjgardne
  • 2
3 Comments
 
LVL 64

Accepted Solution

by:
Fernando Soto earned 2000 total points
ID: 24074122
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
 

Author Closing Comment

by:mjgardne
ID: 31566869
Thanks, Fernando!  I think that I need to visit the eye doctor!  :)
0
 
LVL 64

Expert Comment

by:Fernando Soto
ID: 24083753
Not a problem, glad I was able to help.  ;=)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Integration Management Part 2
Suggested Courses

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question