我写的一个关于编程改变代理的MFC程序 程序运行成功, IE也打开了, 但是我在看我的网站统计时, 只看到有访问, 但访问的IP没有变。
下面是程序代码, 指点一下。
CStdioFile file;
INTERNET_PORT port=80;
CString str,ip,url,html,content;
GetDlgItem(IDC_EDIT1)->GetWindowText(str);
file.Open(str,CStdioFile::modeReadWrite);
while(!feof(file.m_pStream))
{
a:
file.ReadString(ip);
CString dl;
dl.Format("http=%s",ip);
HKEY key=HKEY_CURRENT_USER,key1;
if(ERROR_SUCCESS!=RegOpenKeyEx(key,"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", 0,KEY_CREATE_LINK|KEY_WRITE|KEY_READ|KEY_NOTIFY,&key1))
{
AfxMessageBox(ip);
goto a;
}
ULONG regsize = 0;
if(RegQueryValueEx(key,"ProxyServer",NULL,NULL,NULL,®size)!=ERROR_SUCCESS)
{
CString we("query error1");
AfxMessageBox(we);
goto a;
}
LPBYTE pValue=new BYTE[regsize];
memset(pValue, 0x00, regsize);
if(ERROR_SUCCESS!=RegQueryValueEx(key, "ProxyServer", NULL, NULL, pValue, ®size))
{
CString we("query error");
AfxMessageBox(we);
goto a;
}
int pos=0;
CString oldproxy((char *)pValue);
delete [] pValue;
pValue = NULL;
if(-1==(pos=oldproxy.Find("http=")))
{
pos=0;
}
int pos1=0;
if(-1==(pos1=oldproxy.Find(";",pos)))
{
pos1=oldproxy.GetLength();
}
oldproxy.Delete(pos,pos1-pos);
oldproxy.Insert(pos,ip);
if(ERROR_SUCCESS!=RegSetValueEx(key,"ProxyServer",0,REG_SZ,(const unsigned char*)oldproxy.LockBuffer(),oldproxy.GetLength()+1))
{
CString q("set error");
AfxMessageBox(q);
goto a;
}
RegCloseKey(key);
//使设置生效
if(InternetSetOption(NULL,INTERNET_OPTION_SETTINGS_CHANGED,NULL,0))
{
CString internet("internet");
AfxMessageBox(internet);
ShellExecute(NULL,_T("open"),_T("http://www.xxxxxxxxx.cn"),NULL,NULL,SW_SHOWNORMAL);
AfxMessageBox(ip);
} }
}
下面是程序代码, 指点一下。
CStdioFile file;
INTERNET_PORT port=80;
CString str,ip,url,html,content;
GetDlgItem(IDC_EDIT1)->GetWindowText(str);
file.Open(str,CStdioFile::modeReadWrite);
while(!feof(file.m_pStream))
{
a:
file.ReadString(ip);
CString dl;
dl.Format("http=%s",ip);
HKEY key=HKEY_CURRENT_USER,key1;
if(ERROR_SUCCESS!=RegOpenKeyEx(key,"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", 0,KEY_CREATE_LINK|KEY_WRITE|KEY_READ|KEY_NOTIFY,&key1))
{
AfxMessageBox(ip);
goto a;
}
ULONG regsize = 0;
if(RegQueryValueEx(key,"ProxyServer",NULL,NULL,NULL,®size)!=ERROR_SUCCESS)
{
CString we("query error1");
AfxMessageBox(we);
goto a;
}
LPBYTE pValue=new BYTE[regsize];
memset(pValue, 0x00, regsize);
if(ERROR_SUCCESS!=RegQueryValueEx(key, "ProxyServer", NULL, NULL, pValue, ®size))
{
CString we("query error");
AfxMessageBox(we);
goto a;
}
int pos=0;
CString oldproxy((char *)pValue);
delete [] pValue;
pValue = NULL;
if(-1==(pos=oldproxy.Find("http=")))
{
pos=0;
}
int pos1=0;
if(-1==(pos1=oldproxy.Find(";",pos)))
{
pos1=oldproxy.GetLength();
}
oldproxy.Delete(pos,pos1-pos);
oldproxy.Insert(pos,ip);
if(ERROR_SUCCESS!=RegSetValueEx(key,"ProxyServer",0,REG_SZ,(const unsigned char*)oldproxy.LockBuffer(),oldproxy.GetLength()+1))
{
CString q("set error");
AfxMessageBox(q);
goto a;
}
RegCloseKey(key);
//使设置生效
if(InternetSetOption(NULL,INTERNET_OPTION_SETTINGS_CHANGED,NULL,0))
{
CString internet("internet");
AfxMessageBox(internet);
ShellExecute(NULL,_T("open"),_T("http://www.xxxxxxxxx.cn"),NULL,NULL,SW_SHOWNORMAL);
AfxMessageBox(ip);
} }
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货