写有如下代码,想通过动态改变代理服务器地址来打开网页,可是不奏效,只是在程序刚运行的时候第一个地址会生效,下面的都不会生效。请问是何原因,代码哪里有问题啊。
Reg:=TRegistry.Create;
Reg.RootKey:=HKEY_CURRENT_USER;
if (Reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\Internet Settings',false)) then
begin
Reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\Internet Settings',True);
Reg.WriteString('ProxyServer',ListBox1.Items[ListBox1.ItemIndex]);
Reg.WriteInteger('ProxyEnable',1);
Reg.CloseKey;
end;
web.Free;
web:=Twebbrowser.create(self);
web.FullScreen:=True;
web.Align:=alClient;
web.ParentWindow:=groupbox2.Handle;
web.Top:=14;
web.Left:=2;
web.Width:=Groupbox2.Width;
web.Height:=Groupbox2.Height;
flags:=0;
web.Navigate('http://www.ip138.com',flags,flags,flags,flags);同时还求清楚IE的COOKIES以及IE临时文件的编程方法。谢谢大家

解决方案 »

  1.   

    Reg.CloseKey;
    end;
    后加入: const int SomeTimeoutValue = 1000;
    int result;
    SendMessageTimeout( (System.IntPtr)HWND_BROADCAST,
    WM_SETTINGCHANGE,0,"Environment",SMTO_BLOCK | SMTO_ABORTIFHUNG |
    SMTO_NOTIMEOUTIFNOTHUNG, SomeTimeoutValue, out result);自己修改下成delphi 代码
      

  2.   

    UrlMkSetSessionOption INTERNET_OPTION_PROXY
    http://msdn.microsoft.com/workshop/networking/moniker/reference/functions/urlmksetsessionoption.asp
      

  3.   

    aiir ii的代码是刷新一下环境变量
      

  4.   

    http://community.csdn.net/Expert/topic/4348/4348418.xml?temp=.2641413