S
smileff8
Unregistered / Unconfirmed
GUEST, unregistred user!
我查了大富翁的相关内容得到下面两种程序,结果是一样
情况:
我是用ASDL上网的,有一个“我的连接”(ASDL PPPOE拨号),运行程序后在IE的代理设置没有变,IE设置里的局域网代理服务设置倒是改过成了我设置的代理
程序代码:
unit Unit1;
interface
uses
Windows,Registry, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,wininet, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function ChangeProxy(const Proxy, Port,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]);
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 := pchar(proxy);
info.lpszProxyBypass := pchar(ByPass);
InternetSetOption(nil, INTERNET_OPTION_PROXY, @info, SizeOf(Info));
InternetSetOption(nil, INTERNET_OPTION_SETTINGS_CHANGED, nil, 0);
// InternetSetOption(nil, INTERNET_OPTION_REFRESH, nil, 0);
// Sendmessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0);
Result:=True;
end
finally
reg.CloseKey;
reg.free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
info : INTERNET_PROXY_INFO;
reg : TRegistry;
begin
reg := TRegistry.Create;
reg.RootKey:=HKEY_CURRENT_USER;
if reg.OpenKey('/Software/Microsoft/Windows/CurrentVersion/Internet Settings',False) then
begin
reg.Writestring('ProxyServer','252.168.0.1':'8080');
reg.Writestring('ProxyEnable', '1');
end;
reg.CloseKey;
reg.Free;
info.dwAccessType:=INTERNET_OPEN_TYPE_PROXY;
info.lpszProxy:='172.23.23.23:8888';
InternetSetOption(nil,INTERNET_OPTION_PROXY,@info,1000);
InternetSetOption(nil,INTERNET_OPTION_REFRESH, nil,0);
InternetSetOption(nil,INTERNET_OPTION_SETTINGS_CHANGED, nil,0);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if ChangeProxy('252.168.0.1','8080', '')=true
then showmessage('ok');
end;
end.
Button2Click是通过调用函数,.Button1Click是直接改
不变是点按钮一还是按钮二,得到的结果都是IE设置里的局域网IP变了过来,而拨号连接的没有改过来
为什么 ???
情况:
我是用ASDL上网的,有一个“我的连接”(ASDL PPPOE拨号),运行程序后在IE的代理设置没有变,IE设置里的局域网代理服务设置倒是改过成了我设置的代理
程序代码:
unit Unit1;
interface
uses
Windows,Registry, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,wininet, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function ChangeProxy(const Proxy, Port,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]);
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 := pchar(proxy);
info.lpszProxyBypass := pchar(ByPass);
InternetSetOption(nil, INTERNET_OPTION_PROXY, @info, SizeOf(Info));
InternetSetOption(nil, INTERNET_OPTION_SETTINGS_CHANGED, nil, 0);
// InternetSetOption(nil, INTERNET_OPTION_REFRESH, nil, 0);
// Sendmessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0);
Result:=True;
end
finally
reg.CloseKey;
reg.free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
info : INTERNET_PROXY_INFO;
reg : TRegistry;
begin
reg := TRegistry.Create;
reg.RootKey:=HKEY_CURRENT_USER;
if reg.OpenKey('/Software/Microsoft/Windows/CurrentVersion/Internet Settings',False) then
begin
reg.Writestring('ProxyServer','252.168.0.1':'8080');
reg.Writestring('ProxyEnable', '1');
end;
reg.CloseKey;
reg.Free;
info.dwAccessType:=INTERNET_OPEN_TYPE_PROXY;
info.lpszProxy:='172.23.23.23:8888';
InternetSetOption(nil,INTERNET_OPTION_PROXY,@info,1000);
InternetSetOption(nil,INTERNET_OPTION_REFRESH, nil,0);
InternetSetOption(nil,INTERNET_OPTION_SETTINGS_CHANGED, nil,0);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if ChangeProxy('252.168.0.1','8080', '')=true
then showmessage('ok');
end;
end.
Button2Click是通过调用函数,.Button1Click是直接改
不变是点按钮一还是按钮二,得到的结果都是IE设置里的局域网IP变了过来,而拨号连接的没有改过来
为什么 ???