16,472
社区成员
发帖
与我相关
我的任务
分享
BOOL SetProxy(const string &strFullAddr)
{
BOOL bResult;
HKEY phKResult;
DWORD dwcode = 0;
LPCTSTR pchSubKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
RegOpenKeyEx(HKEY_CURRENT_USER, pchSubKey, 0, KEY_ALL_ACCESS, &phKResult); //打开注册表
int i = 1;
RegSetValueEx(phKResult, "ProxyServer", 0, REG_SZ,(LPBYTE)strFullAddr.c_str(), strFullAddr.size()+1);//设置注册表键值
RegCloseKey(phKResult);
EnableProxy(true);//获得打开代理允许
bResult = InternetSetOption(NULL, INTERNET_OPTION_SETTINGS_CHANGED, NULL, 0); //通知注册表中代理改变,下次连接时启动代理
bResult = InternetSetOption(NULL ,INTERNET_OPTION_REFRESH , NULL, 0); //从注册表中读入代理
DWORD size = sizeof(dwcode);
return bResult;
}