Hi all
Just a follow up to my earlier post, this is how tmp2 is being passed to RegSetValueEx
Code:
sprintf(value11, "ValueName");
RegOpenKeyEx(HKEY_LOCAL_MACHINE,(LPCTSTR)&srcKeyName,0,KEY_SET_VALUE, &Gt5Key);
if (setValue_multi_sz(Gt5Key, value11, tmp2) == true)
{
printf("---Success in setting new ValueName\n");
}
else
{
printf("---Failure in setting value of ValueName under %s , errorcode is: %d\n",srcKeyName, GetLastError());
}
bool setValue_multi_sz(HKEY hKey, const char *valueName, char* value) {
//indent++;
bool rc = true;
DWORD result = RegSetValueEx(hKey, valueName, 0,REG_MULTI_SZ, reinterpret_cast <CONST BYTE *>(value), strlen(value)+1);
if (NO_ERROR != result) {
//MessageBox(hWnd, valueName, "setValue error", MB_OK);
printf(msgbuff, "ERROR: RegSetValueEx(%s:%s) failed with error code %d.\n", valueName, value, result);
// LogMessage(hModule, (LPCTSTR)msgbuff);
rc = false;
}
else {
printf("\t to set %s=%s\n", valueName, value);
// LogMessage(hModule, (LPCTSTR)msgbuff);
}
// indent--;
return rc;
}