我有读取注册表项中的键的应用程序。
它的工作很好Multi-Byte Character Set
但是在Unicode character set
它无法打开密钥
这是我的代码:
HKEY hkey = 0;
char buf[255] = {0};
DWORD dwType = 0;
DWORD dwBufSize = sizeof(buf);
const char* subkey_x64 = "SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\UCP";
const char* subkey_x86 = "SOWTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\UCP";
if (RegOpenKey(HKEY_LOCAL_MACHINE, (LPCWSTR)subkey_x64, &hkey) == ERROR_SUCCESS)
{
dwType = REG_SZ;
if (RegQueryValueEx(hkey, (LPCWSTR)"DisplayIcon", 0, &dwType, (BYTE*)buf, &dwBufSize) == ERROR_SUCCESS)
{
cout << "Key Value IS: " << buf << endl;
}
else
{
cout << "Cannot get key value..." << endl << endl;
}
}
else
{
cout << "Cannot open key\n" << endl << endl;
RegCloseKey(HKEY_PERFORMANCE_DATA);
}
有人知道为什么它不能打开密钥吗?
(LPCWSTR) 不是好办法吗?
我正在使用视觉工作室 2010