当前位置: 首页 > 图文教程 > 开发语言 > Delphi > 用Delphi检测IE使用的代理服务器

Delphi
Delphi实现窗体控件自由摆布
利用Delphi编制IP地址转换器
用Indy组件开发Socket应用程序
Delphi模拟最小化恢复关闭按纽
简析XML及其在Delphi中的应用
Delphi开发基于DCOM的聊天室
Delphi实现远程串口的数据采集
Delphi托盘编程实战演练
在Delphi中使用电子邮件
Delphi开发98屏幕保护预览程序
Delphi实现同类型文档自动合并
Delphi 8 For .NET 抢先预览
Delphi图像存取另类解决方案
用Delphi实现动态获取版本信息
用Delphi客户端访问EJB组件
Delphi中数据网格DBGrid应用
Delphi数据库控件使用入门
Delphi下的COM编程技术简介
用Delphi轻松实现背景播放
也谈TTreeView、TListView用法

用Delphi检测IE使用的代理服务器


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-30   浏览: 39 ::
收藏到网摘: n/a

 
如果我们开发的对象,不是在公网的环境内上网,是使用内网的,我们应该怎么样检测你的IE使用的代理服务器呢?接下来我们通过以下实例来学习:
  



  //-----------------------------------------------
  //记得引用 WinInet 单元
  //-----------------------------------------------
  uses
  WinInet

  //----------------------------------------------
  //定义要使用的函数
  //----------------------------------------------

  function GetProxyInformation: string;
  var
  ProxyInfo: PInternetProxyInfo;
  Len: LongWord;
  begin
  Result := '';
  Len := 4096;
  GetMem(ProxyInfo, Len);
  try
  if InternetQueryOption(nil, INTERNET_OPTION_PROXY, ProxyInfo, Len) then
  if ProxyInfo^.dwAccessType = INTERNET_OPEN_TYPE_PROXY then
  begin
  Result := ProxyInfo^.lpszProxy
  end;
  finally
  FreeMem(ProxyInfo);
  end;
  end;

  procedure GetProxyServer(protocol: string; var ProxyServer: string;
  var ProxyPort: Integer);
  var
  i: Integer;
  proxyinfo, ps: string;
  begin
  ProxyServer := '';
  ProxyPort := 0;

  proxyinfo := GetProxyInformation;
  if proxyinfo = '' then
  Exit;

  protocol := protocol + '=';



  i := Pos(protocol, proxyinfo);
  if i > 0 then
  begin
  Delete(proxyinfo, 1, i + Length(protocol));
  i := Pos(';', ProxyServer);
  if i > 0 then
  proxyinfo := Copy(proxyinfo, 1, i - 1);
  end;

  i := Pos(':', proxyinfo);
  if i > 0 then
  begin
  ProxyPort := StrToIntDef(Copy(proxyinfo, i + 1, Length(proxyinfo) - i), 0);
  ProxyServer := Copy(proxyinfo, 1, i - 1)
  end
  end;
  //----------------------------------------------------------------
  //使用范例
  //----------------------------------------------------------------
  procedure TForm1.Button1Click(Sender: TObject);
  var
  ProxyServer: string;
  ProxyPort: Integer;
  begin
  GetProxyServer('http', ProxyServer, ProxyPort);
  if  ProxyPort=0 then
  begin
  ShowMessage('你的IE没有使用的代理服务器')
  end
  else
  Label1.Caption := ProxyServer;
  label2.Caption := IntToStr(ProxyPort);

  end;