看看以下代码
HKEY hKey = 0;
int code = RegOpenKey(HKEY_CURRENT_USER, subkey, &hKey); //code is ERROR_SUCCESS
char aBuf[255] = {0};
char bBuf[255] = {0};
DWORD dwType = REG_SZ;
DWORD dwBufSize = sizeof(bBuf);
int aCode = RegQueryValueEx(hKey, L"a", 0, &dwType, (BYTE*)aBuf, &dwBufSize);
int bCode = RegQueryValueEx(hKey, L"b", 0, &dwType, (BYTE*)bBuf, &dwBufSize);
//(*) here I have a breakpoint
断点aBuf
(以及bBuf
)类似'a' '\0' 'v' '\0' 'a' '\0' 'l' '\0' 'u' '\0' 'e' '\0'
。我做错了什么?
提前谢谢!
答案 0 :(得分:5)
您的代码编译为UNICODE(由您使用L“a”证明),因此结果将是wchar_t数组,而不是char数组。
答案 1 :(得分:1)
听起来你有UTF16编码问题。将字符串解码为UTF16,你应该没问题。