uses UrlMon, WinInet; {------------------------------------------------------------------------------- 过程名: SetProcessProxy 作者: kelei 日期: 2013.08.03 参数: aProxyServer代理服务器; aProxyPort代理服务器端口 返回值: True设置成功 SetProcessProxy('127.0.0.1', 80); -------------------------------------------------------------------------------} function SetProcessProxy(const aProxyServer: string; const aProxyPort: Integer): Boolean; var vProxyInfo: TInternetProxyInfo; begin vProxyInfo.dwAccessType := INTERNET_OPEN_TYPE_PROXY; vProxyInfo.lpszProxy := PChar(Format('http=%s:%d', [aProxyServer, aProxyPort])); vProxyInfo.lpszProxyBypass := PChar(''); Result := UrlMkSetSessionOption(INTERNET_OPTION_PROXY, @vProxyInfo, SizeOf(vProxyInfo, 0) = S_OK; end; {------------------------------------------------------------------------------- 过程名: SetProcessUserAgent 作者: kelei 日期: 2013.08.03 参数: aUserAgent HTTP请求头UserAgent内容 返回值: True设置成功 SetProcessUserAgent('Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3') -------------------------------------------------------------------------------} function SetProcessUserAgent(const aUserAgent: string): Boolean; begin Result := UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, PChar(aUserAgent), Length(aUserAgent), 0) = S_OK; end;
标签: Delphi
posted @ 1456)
评论(收藏
请发表评论