error C2664: 'MessageBoxW' : cannot convert parameter 3 from 'const char [22]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
我正在尝试执行以下代码并获得上述错误。
bool RegistryHandler::readRegistryEntry(String^ referencePath, String^ keyName, String ^keyValue)
{
HKEY keyHandle;
LPCTSTR sk = TEXT("SOFTWARE\\Microsoft\\Office\\Outlook\\Addins\\GoToApp");
wchar_t rgValue [1024];
wchar_t fnlRes [1024];
DWORD size1;
DWORD Type;
if( RegOpenKeyEx(HKEY_CURRENT_USER, sk,0,KEY_QUERY_VALUE, &keyHandle) == ERROR_SUCCESS)
{
size1=1023;
RegQueryValueEx( keyHandle,L"ApplicationUrl", NULL, &Type,(LPBYTE)rgValue,&size1);
MessageBoxW(NULL,L"inside for readindg",L"Native Addin",MB_OK);
MessageBoxW(NULL,rgValue, "Product ID of Windows", MB_OK);
}
else {
MessageBoxW(NULL,L"inside for else",L"Native Addin",MB_OK);
}
RegCloseKey(keyHandle);
return true ;
}
如何正确获取rgvalue ???
plse vc ++新手
答案 0 :(得分:7)
在“Windows的产品ID”字符串之前缺少“L”。它应该是:
MessageBoxW(NULL,rgValue, L"Product ID of Windows", MB_OK);