0

I need to read key values in HKEY_LOCAL_MACHINE\SOFTWARE from my application. I use the following snippet to do that but it always returns 2.

std::wstring strTmp;
strTmp = L"SOFTWARE\\TEMP";
RegOpenKeyExW(HKEY_LOCAL_MACHINE, strTmp.c_str(), 0, KEY_READ, &hKey))

But when I use HKEY_CURRENT_USER then I'm able to read information successfully from HKEY_CURRENT_USER\SOFTWARE. I understand that my application is unable to read from HKEY_LOCAL_MACHINE due to access privileges. I did run my application with administrator privileges (using Run As) but that did not help me out.

Can someone shed some light on how can I access the HKEY_LOCAL_MACHINE using RegOpenKeyExW.

I did go through the links 1, 2 but that did not help me out,

4

1 回答 1

1

对于我的误解,我深表歉意。实际上,我必须使用KEY_WOW64_32KEYflag 而不是KEY_WOW64_64KEYinRegOpenKeyExW(HKEY_LOCAL_MACHINE, strTmp.c_str(), 0, KEY_READ | KEY_WOW64_32KEY, &hKey))才能使我的应用程序正常工作。感谢穆罕默德·埃尔加维。

于 2015-11-02T06:51:29.383 回答