I’m trying to write data to registry, but it always writes foreigner language instead because the setvalue is “MyApp”
CStringA temp(setvalue);//setvalue is CString type
const BYTE* pData = (const BYTE*)(LPCSTR)temp;
lResult = RegSetValueEx(hKey, path, NULL, REG_SZ, (LPBYTE)pData, sizeof(pData));
RegCloseKey(hKey);
if(lResult == ERROR_SUCCESS || lResult == ERROR_MORE_DATA)
return true;
else
return false;
thanks.
The way you are converting CString to BYTE* is causing the problem. No need of using CStringA.
Try this conversion of CString to TCHAR. This should work