通过代理服务器 访问 Internet页面。
来源:互联网 发布:团队文档库 mac 编辑:程序博客网 时间:2024/05/18 00:59
_hHTTPOpen=::InternetOpen(szAgent, // agent name
INTERNET_OPEN_TYPE_PRECONFIG, // proxy option
"", // proxy
"", // proxy bypass
0); // flags
if(!_hHTTPOpen){
_dwError=::GetLastError();
#ifdef _DEBUG
LPVOID lpMsgBuffer;
DWORD dwRet=FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
::GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
reinterpret_cast<LPTSTR>(&lpMsgBuffer),
0,
NULL);
OutputDebugString(reinterpret_cast<LPTSTR>(lpMsgBuffer));
LocalFree(lpMsgBuffer);
#endif
return FALSE;
}
_hHTTPConnection=::InternetConnect( _hHTTPOpen, // internet opened handle
szAddress, // server name
nPort, // ports
szUserAccount, // user name
szPassword, // password
INTERNET_SERVICE_HTTP, // service type
INTERNET_FLAG_KEEP_CONNECTION | INTERNET_FLAG_NO_CACHE_WRITE, // service option
0); // context call-back option
if(!_hHTTPConnection){
_dwError=::GetLastError();
::CloseHandle(_hHTTPOpen);
#ifdef _DEBUG
LPVOID lpMsgBuffer;
DWORD dwRet=FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
::GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
reinterpret_cast<LPTSTR>(&lpMsgBuffer),
0,
NULL);
OutputDebugString(reinterpret_cast<LPTSTR>(lpMsgBuffer));
LocalFree(lpMsgBuffer);
#endif
return FALSE;
}
if(::InternetAttemptConnect(NULL)!=ERROR_SUCCESS){
_dwError=::GetLastError();
::CloseHandle(_hHTTPConnection);
::CloseHandle(_hHTTPOpen);
#ifdef _DEBUG
LPVOID lpMsgBuffer;
DWORD dwRet=FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
::GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
reinterpret_cast<LPTSTR>(&lpMsgBuffer),
0,
NULL);
OutputDebugString(reinterpret_cast<LPTSTR>(lpMsgBuffer));
LocalFree(lpMsgBuffer);
#endif
return FALSE;
}
// Set Proxy
if(1==nNeedProxy)
{
/* set proxy information */
INTERNET_PROXY_INFO proxyinfo;
proxyinfo.dwAccessType = INTERNET_OPEN_TYPE_PROXY;
proxyinfo.lpszProxy = _szProxyList;
proxyinfo.lpszProxyBypass = NULL;
InternetSetOption(_hHTTPConnection,
INTERNET_OPTION_PROXY,
(LPVOID)&proxyinfo,
sizeof(INTERNET_PROXY_INFO));
InternetSetOption(_hHTTPConnection,INTERNET_OPTION_PROXY_USERNAME, _szProxyUserName, strlen(_szProxyUserName)+1);
InternetSetOption(_hHTTPConnection,INTERNET_OPTION_PROXY_PASSWORD, _szProxyPassword, strlen(_szProxyPassword)+1);
}
return TRUE;
- 通过代理服务器 访问 Internet页面。
- 在xp上通过vmware装ubuntu,并让ubuntu通过代理服务器访问Internet
- 通过Internet访问 SharePoint
- 通过代理服务器访问SFTP问题解决
- 通过注册表获取Internet选项中代理服务器参数
- 网外(Internet)访问代理服务器内部的实现方法
- NET中,WebClient通过代理服务器访问网页
- 设置VSS2005使支持通过Internet访问
- 设置VSS2005使支持通过Internet访问
- 设置VSS使支持通过Internet访问
- 设置VSS2005使支持通过Internet访问
- 设置VSS2005使支持通过Internet访问
- 设置VSS2005使支持通过Internet访问
- 设置VSS使支持通过Internet访问
- 设置VSS使支持通过Internet访问
- 通过Internet访问局域网内部ip
- VSS2005使支持通过Internet访问
- VC通过代理访问internet例子
- 我的痛苦
- Microsoft Visual Studio 2008(vs2008) 中集成Qt4
- ASP.net获取当前url属性(文件名、参数、域名 等)的方法
- Halcon学习之八:图像区域叠加与绘制
- Qt4连接SQL Server
- 通过代理服务器 访问 Internet页面。
- date time 格式。。。。
- 关于字节对齐
- Qt Creator系列教程地址
- 属性项目的定义(property)
- 如何将中文输出为UTF-8字符
- 3-----强类型DataContext
- SQL中的交叉连接(CROSS JOIN)、内连接(INNER JOIN)、外连接(OUTER JOIN)
- 关于Vc2005中头文件的static const int问题