Solved

.NET RegistryKey::OpenSubKey not working

Posted on 2009-04-05
3
529 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
reading excel file in .net 2 46
Telerik RadEditor Control Save 8 39
Nested forach loop to linq 3 43
Help with Report Viewer in VS2013 6 33
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

751 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