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

Delphi
在线播放器DIY
关于VisiBroker For Delphi的使用(3)
关于VisiBroker For Delphi的使用(2)
关于VisiBroker For Delphi的使用(1)
Delphi的两个实用技巧(2)巧用Windows的API函数
Delphi的两个实用技巧(1)播放Flash
delphi学习:两种方法使用xml文档
Delphi与Word之间的融合技术
Delphi中动态链接库(DLL)的建立和使用
Delphi基础:Window 消息大全使用详解下
Delphi基础:Window 消息大全使用详解上
教你在DELPHI中如何调用系统对话框
Delphi开发单机瘦小数据库程序要点
用Delphi + DirectX开发简单RPG游戏
Delphi7从入门到精通之认识Delphi编辑器
Delphi7从入门到精通之历数Delphi七个版本
Delphi学习:图像放大漫游攻略
用编程来实现24小时制到12小时制的转换
一个实际的OLE服务器的开发
Delphi一点通:如何将源代码学好

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-30   浏览: 48 ::
收藏到网摘: 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;