const char [22]' to 'LPCWSTR'


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 ;
}

如何正确获取 RG值 ???

请帮助 Vc++ 的新手

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

MessageBoxW(NULL,rgValue, L"Product ID of Windows", MB_OK);

最新更新