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

Delphi
回调函数与Delphi的事件模型
Delphi中如何实现透明按钮
用Delphi编写打印程序的窍门
自己制作网页特效软件
Delphi+Cell全攻略
开发基于DCOM的局域网聊天室(一)
用简单的Tracer类来为应用写入跟踪
快捷方式/删除项/EXE自删除DIY
排序Select中Option项的一个示例
QQ聊天记录器演示程序(二)
QQ聊天记录器演示程序(一)
Delphi单元文件详解
Delphi学习:在Listbox加背景图
Delphi7目录结构----初学者参考
Delphi学习:在流中查找任意字串
制作一个IPhunter
播放自定义的声音
利用Dephi5编写控制面板程序
用Delphi编写Win2000服务程序
Spcomm串口控件的例程

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


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