更改 IE 代理服务器设置 ,不重新启动 IE,代码如下 :
但如何设置某种协议为一特定地址呢 ,BYPASS 参数怎么用 ?
其实在 proxyserver 中 http=205.207.118.51:80;https=205.207.118.51:80;gopher=205.207.118.51:80;socks=205.207.118.51:80 是分别设置 ,如果只有地址和端口则是所有协议使用相同地址
1 function ChangeProxy(const Proxy, Port,ByPass: string; const bEnabled: boolean = True): boolean; 2 3 var 4 5 reg: Tregistry; 6 7 info: INTERNET_PROXY_INFO; 8 9 Fproxy:string; 10 11 begin 12 13 Result := False; 14 15 FProxy:=Format(‘%s:%s‘,[Proxy,Port]); 16 17 reg := Tregistry.Create; 18 19 try 20 21 reg.RootKey := HKEY_CURRENT_USER; 22 23 if reg.OpenKey(‘\Software\Microsoft\Windows\CurrentVersion\Internet Settings‘, True) then 24 25 begin 26 27 reg.Writestring(‘ProxyServer‘, Fproxy); 28 29 reg.WriteInteger(‘ProxyEnable‘, integer(bEnabled)); 30 31 info.dwAccessType := INTERNET_OPEN_TYPE_PROXY; 32 33 info.lpszProxy := pchar(proxy); 34 35 info.lpszProxyBypass := pchar(ByPass); 36 37 InternetSetOption(nil, INTERNET_OPTION_PROXY, @info, SizeOf(Info)); 38 39 InternetSetOption(nil, INTERNET_OPTION_SETTINGS_CHANGED, nil, 0); 40 41 // InternetSetOption(nil, INTERNET_OPTION_REFRESH, nil, 0); 42 43 // Sendmessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0); 44 45 Result:=True; 46 47 end 48 49 finally 50 51 reg.CloseKey; 52 53 reg.free; 54 55 end; 56 57 end;
1 user urlmon,wininet; 2 3 procedure qiehuanproxy(const proxyname:string); 4 5 var info:TInternetProxyInfo; 6 7 lngth:integer; 8 9 h:integer; 10 11 proxy :pChar; 12 13 bypass :PChar; 14 15 begin 16 17 proxy:=pchar(proxyname);//proxy address:port 18 19 bypass:=pChar(‘‘); 20 21 info.dwAccessType := INTERNET_OPEN_TYPE_PROXY ; 22 23 info.lpszProxy :=proxy; 24 25 info.lpszProxyBypass:=bypass; 26 27 lngth:=sizeof(info); 28 29 h:=UrlMkSetSessionOption(INTERNET_OPTION_PROXY ,@info,lngth,0); 30 31 end; 32 33 InternetSetOption(nil,INTERNET_OPTION_REFRESH, nil,0); 34 35 InternetSetOption(nil,INTERNET_OPTION_SETTINGS_CHANGED, nil,0);
时间: 2024-10-12 16:31:03