对于下面的代码,在尝试打开 HKLM\Security 时,我没有收到任何错误,但返回码非零。返回代码为 5,ResultC9
即拒绝访问。密钥存在于注册表中(通过 Regedit 确认)。我在这里阅读了 MSDN 文章,但这对我没有帮助。请告知为什么我得到“5”/“访问被拒绝” ResultC9
?
HKEY hKey5;
long resultC9 = ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SECURITY", 0, KEY_READ, &hKey5);
std::cout << "Value of GetLastError() is: " << GetLastError() << endl; // "0" is output to screen!
std::wcout << "Value of resultC9 is: " << resultC9 << endl; // "5" is output to screen.