HKEY_USERS访问Wow6432Node

时间:2016-11-15 14:57:55

标签: c++ registry poco access

这是我想列出的程序:

  

HKEY_USERS / User_SID / Wow6432Node /软件/微软/在Windows / CURRENTVERSION /卸载/

#include "pch.h"

void _tmain(int argc, TCHAR* argv[])
{
    try
    {
        HKEY root = HKEY_USERS;
        std::string sid("S-1-5-21-1917061056-2319448781-3348045073-1000");
        std::string subKey(sid + "\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\");
        Poco::Util::WinRegistryKey key(root, subKey, true, KEY_WOW64_32KEY);

        Poco::Util::WinRegistryKey::Keys keys;
        if (key.exists())
        {
            key.subKeys(keys);
        }
    }
    catch (const std::exception& e)
    {
        _tcout << _T("Error occurred: ") << e.what() << std::endl;

        _tostringstream error;
        error << L"Error: " << e.what();
        ::MessageBox(NULL, error.str().c_str(), L"Error occurred", MB_ICONERROR);
    }
}

据我所知,为switch between 64 and 32 registry keys我们需要使用KEY_WOW64_32KEY和KEY_WOW64_64KEY访问掩码。所以我使用的是KEY_WOW64_32KEY,但我的程序总是列出:

  

HKEY_USERS / User_SID /软件/微软/在Windows / CURRENTVERSION /卸载/

我做错了什么?

P.S:如果我们在HKEY_LOCAL_MACHINE上更改HKEY_USERS,程序将正常运行。

0 个答案:

没有答案
相关问题