change registry from C++ ?

anton

Banned
Sep 15, 2000
746
0
0
Hello,

I really need help , I need to change one registry value from within my program , how would I do it ? ... I need to change this (
proxyserver) to other value :


[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
"ProxyServer"="something:8080"


really apreciate it, thanks ; )
 

juiio

Golden Member
Feb 28, 2000
1,433
4
81
Use these:

LONG RegOpenKey(
HKEY hKey, // handle to open key
LPCTSTR lpSubKey, // name of subkey to open
PHKEY phkResult // handle to open key
);

LONG RegSetValueEx(
HKEY hKey, // handle to key
LPCTSTR lpValueName, // value name
DWORD Reserved, // reserved
DWORD dwType, // value type
CONST BYTE *lpData, // value data
DWORD cbData // size of value data
);

LONG RegCloseKey(
HKEY hKey // handle to key to close
);

For more info, go to msdn.microsoft.com and use the search function.
 

anton

Banned
Sep 15, 2000
746
0
0
got it ... does this looks right :



ret=RegOpenKey(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings",reghandle);
RegSetValueEx(reghandle,"ProxyServer",0,REG_SZ,"aaa:111",7);
Edit1->Text=ret;
RegCloseKey(reghandle);


then why do I get 87 in ret ; (