开发者

c++ get registry key returns only one char

I'm trying to retrieve a value of a key but i'm only getting the first char of the value.. can anyone help?

my code:

void dealWithRegistry()
{
    HKEY regkey1;
    char data[100];
    DWORD datasize = sizeof (data) / sizeof (char);
    LONG rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_READ, &regkey1);
    if (rc != ERROR_SUCCESS)
    {
        cout << "there was a problem openning" << endl;
    }
    else
    {
        rc = RegGetValue (regkey1, NULL, L"AppData", RRF_RT_REG_SZ, NULL, (void*) data, &datasize);
        if (rc != ERROR_SUCCESS)
        {
            cout << d开发者_StackOverflow中文版ata << endl;
            cout << "there was a problem getting the value" << endl;
        }
    }
    cout << data << endl;

}


It is probably returning Unicode data and you are only printing the first character. A quick test of that would be to change the call to RegGetValueA.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜