delphi设置ie代理的方法


本文整理自网络,侵删。

 
uses UrlMon, WinInet,registry;

 //设置代理
function ChangeProxy(const Proxy,ByPass: string; const bEnabled: boolean = True): boolean;
var
  reg: Tregistry;
  info: INTERNET_PROXY_INFO;
  Fproxy: string;
begin
  Result := False;
  //FProxy :=Format('%s:%s',[Proxy,Port]);
  Fproxy := Proxy;
  reg :=Tregistry.Create;
  try
    reg.RootKey :=HKEY_CURRENT_USER;
    if reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\Internet Settings', True) then
    begin
      reg.Writestring('ProxyServer', Fproxy);
      reg.WriteInteger('ProxyEnable', integer(bEnabled));
      info.dwAccessType :=INTERNET_OPEN_TYPE_PROXY;
      info.lpszProxy :=pansichar(proxy);
      info.lpszProxyBypass :=pansichar(ByPass);
      InternetSetOption(nil, INTERNET_OPTION_PROXY, @info, SizeOf(Info));
      InternetSetOption(nil, INTERNET_OPTION_SETTINGS_CHANGED, nil, 0);
      Result:=True;
    end
  finally
    reg.CloseKey;
    reg.free;
  end;
end;
{调用:

//设置代理
ChangeProxy('192.168.1.2:8080','1',true);
//取消代理
ChangeProxy('192.168.1.2:8080','1',False);
}

相关阅读 >>

Delphi 如何判断clipboard剪切板中的内容的类型

Delphi定时器相关的简单例子

Delphi 实现放大效果

Delphi 10 seattle中使用本地通知,请使用tnotificationcenter组件

Delphi 删除文件的函数

Delphi 获取 access 数据库所有表

Delphi 进程程序多开调用单元

Delphi fmx 切换窗体最大化

Delphi实现使用tidhttp控件向https地址post请求

Delphi textfile读取文本文件

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...