阅读用户辅助注册表项c ++

时间:2012-11-08 01:59:27

标签: c++ registry

出于某种原因,当我尝试使用keyRegOpenKey()打开注册表时,该函数返回错误(它返回数字2)。我怎样才能解决这个问题?我的IDE是代码块,我正在使用Windows XP机器。提前谢谢!

#include <iostream>
#include <windows.h>

using namespace std;

int main()
{
    //{75048700-ef-11-d0-9888-006097deac}
    HKEY var;
    char bob[1900];
    int k;
    k = RegOpenKey(HKEY_CURRENT_USER,"software\\microsoft\\windows\\currentVersion\\explorer\\UserAssist\\{75048700-ef-11-d0-9888-006097deac}\\count",&var);

    if (k==ERROR_SUCCESS)
    {
        cout<<"CALL 1 WAS SUCCESSFULL : "<<var<<" "<<k<<endl;
        if (RegEnumKey(var,0,bob,200)==ERROR_SUCCESS)
        {
            cout<<"CALL 2 WAS SUCCESSFULL "<<bob<<endl;
        }
        else
        {
            cout<<"CALL 2 FAILED: "<<bob<<endl;
        }
    }
    else
    {
        cout<<"CALL WAS NOT SUCCESSFULL "<<var<<" "<<k<<endl;
    }

    RegCloseKey(var);

    return 0;
}

0 个答案:

没有答案