Solved

.NET RegistryKey::OpenSubKey not working

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

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 62

Expert Comment

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

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now