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

平乡女银

平乡女银

2016-01-29 14:04

用Delphi检测IE使用的代理服务器,用Delphi检测IE使用的代理服务器
 
如果我们开发的对象,不是在公网的环境内上网,是使用内网的,我们应该怎么样检测你的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;

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/delphi/)

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

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/delphi/)

  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;



 
展开更多 50%)
分享

猜你喜欢

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

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

查看IE是否设置代理服务器

浏览器
查看IE是否设置代理服务器

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

RedHat打造代理服务器

电脑网络
RedHat打造代理服务器

教你用代理服务器登录QQ

电脑入门
教你用代理服务器登录QQ

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

Firefox怎样设置代理服务器

浏览器
Firefox怎样设置代理服务器

什么是快车代理服务器

电脑网络
什么是快车代理服务器

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

《天天炫斗》升级技能装备全面攻略

《天天炫斗》升级技能装备全面攻略

动态链接库编程(二)

动态链接库编程(二)
下拉加载更多内容 ↓