c ++ get注册表项只返回一个char [英] c++ get registry key returns only one char
本文介绍了c ++ get注册表项只返回一个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?
我的代码:
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, ®key1);
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 << data << endl;
cout << "there was a problem getting the value" << endl;
}
}
cout << data << endl;
}
推荐答案
可能返回Unicode数据,并且您只打印第一个字符。一个快速测试是更改对 RegGetValueA
的调用。
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
.
这篇关于c ++ get注册表项只返回一个char的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文