无法在C ++中读取注册表项 [英] Cannot read Registry entry in C++
问题描述
我有一个注册表项,我似乎无法在C ++中读取,但它显示在 Regedit
。
使用以下C ++代码段:
openResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE,_TEXT(SOFTWARE\\ Microsoft \ \ NET Framework Setup\\NDP\\v4\\Full),0,KEY_READ和& root);
readResult1 = RegQueryValueEx(root,_TEXT(InstallPath),NULL,NULL,data1,& size);
readResult2 = RegQueryValueEx(root,_TEXT(fake_entry),NULL,NULL,data2,& size);
我收到错误2, ERROR_FILE_NOT_FOUND
第二个 RegQueryValueEx()
调用。
如下图所示, fake_entry 。
我通过 Regedit
创建了此条目。
Microsoft的。
阅读 fake_entry
SOFTWARE \\ Wow6432Node \\Microsoft \\NET Framework Setup \\NDP\\v4\\Full
有相同的错误。在Visual Studio 2010中使用ASCII字符编码运行Windows 7,64位,C ++。
我误解了注册表重定向器?
我的代码有问题吗?
在注册表的某些部分是否有某种权限设置?我明显缺少一些东西。
尝试
openResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE,_TEXT(SOFTWARE\\Microsoft\\NET Framework Setup\\\\\\\\\\Full),0, KEY_READ | KEY_WOW64_64KEY,& root);
根据 MSDN 应使用 KEY_WOW64_64KEY
或 KEY_WOW64_32KEY
用于WOW64访问
I have a registry entry I can't seem to read in C++, but it shows up in Regedit
.
Using the following C++ snippet:
openResult=RegOpenKeyEx( HKEY_LOCAL_MACHINE, _TEXT("SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full"), 0, KEY_READ, &root);
readResult1=RegQueryValueEx(root, _TEXT("InstallPath"), NULL, NULL, data1, &size);
readResult2=RegQueryValueEx(root, _TEXT("fake_entry"), NULL, NULL, data2, &size);
I get Error 2, ERROR_FILE_NOT_FOUND
for my second RegQueryValueEx()
call.
As you can see in the image below, my fake_entry
exists.
I created this entry via Regedit
.
Microsoft's Registry Keys Affected by WOW64 does not include the location I'm trying to read, and as you can see in the picture below, my fake_entry
is not in the Wow6432Node
location.
- Yes, I understand this isn't a registry location I should be changing. I stumbled upon this as I was debugging my code and am curious why my added
fake_entry
doesn't work. - Yes, I've read about Registry Redirector.
- Yes, I've read this question.
- Yes, I tried reading
fake_entry
atSOFTWARE\\Wow6432Node\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full
with the same error.
Running Windows 7, 64 bit, C++ in Visual Studio 2010, using ASCII character encoding.
Am I misunderstanding the Registry Redirector? Is there a problem with my code? Are there some sort of permission settings on certain portions of the Registry? I'm obviously missing something. Please point me in the right direction.
Try
openResult = RegOpenKeyEx( HKEY_LOCAL_MACHINE, _TEXT("SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full"), 0, KEY_READ|KEY_WOW64_64KEY, &root);
according to MSDN you should use either KEY_WOW64_64KEY
or KEY_WOW64_32KEY
for WOW64 access
这篇关于无法在C ++中读取注册表项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!