1
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 ???

请帮助新的 Vc++

4

1 回答 1

7

“Windows 的产品 ID”字符串前缺少“L”。它应该是:

MessageBoxW(NULL,rgValue, L"Product ID of Windows", MB_OK);
于 2012-04-25T08:37:38.460 回答