?
Mein Fehler...schon entdeckt und geändert:
void CremoteregistryDlg::OnBnClickedButton1()
{
addReg("\\\\127.0.0.1", HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion", "Max Muster", "MyValue");
}
bool CremoteregistryDlg::addReg(CString sMachine, HKEY hDicRot, CString server_path, CString valPath, CString valNamePath)
{
HKEY hKey = NULL;
HKEY hSourcesKey = NULL;
LONG RegCon;
CString BackPath;
BackPath=valPath;
RegCon = RegConnectRegistry((LPCTSTR)sMachine, hDicRot, &hKey);
if (RegCon == ERROR_SUCCESS)
{
MessageBox("connect ok!");
if (ERROR_SUCCESS == RegOpenKeyEx(hKey, server_path,0,KEY_SET_VALUE,&hSourcesKey))
{
MessageBox("open ok!");
if(RegSetValueEx(hSourcesKey,valNamePath,0,REG_SZ,(CONST BYTE*)(LPCTSTR)BackPath,strlen(BackPath)+1)== ERROR_SUCCESS)
{
MessageBox("reg add ok!");
}
else
{
MessageBox("reg add fehler!");
}
}
else
{
MessageBox("open fehler!");
}
}
else
{
MessageBox("connect fehler!");
}
RegCloseKey(hSourcesKey);
RegCloseKey(hKey);
return true;
}