Solved

.NET RegistryKey::OpenSubKey not working

Posted on 2009-04-05
3
527 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 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 63

Expert Comment

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

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…

762 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