Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

.NET RegistryKey::OpenSubKey not working

Posted on 2009-04-05
3
Medium Priority
?
533 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 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

721 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