Mega Code Archive

 
Categories / Delphi / LAN Web TCP
 

Changing Internet Explorers Proxy Settings

Title: Changing Internet Explorers Proxy Settings Question: How do I set the proxy settings in Internet Explorer without having to restart IE to make it load the settings Answer: Ok, I've spent the last 6 days looking for a solution for this. And what I have achived is below. It's not the best solution, this I know, but it worked for me, and I couldn't get the BEST solution to work. Here Goes... Add WinInet and Registry to your uses clause. Procedure EnableProxy(cost Server: String); var Reg : TRegistry; begin Reg := TRegistry.Create; Reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Internet Settings',False); Reg.WriteString('ProxyServer',Server); Reg.WriteBool('ProxyEnable,True); Reg.CloseKey; Reg.Free; InternetSetOption(0, INTERNET_OPTION_SETTINGS_CHANGED, 0, 0); end; Procedure DisableProxy; var Reg : TRegistry; begin Reg := TRegistry.Create; Reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Internet Settings',False); Reg.WriteBool('ProxyEnable,False); Reg.CloseKey; Reg.Free; InternetSetOption(0, INTERNET_OPTION_SETTINGS_CHANGED, 0, 0); end; You can simply execute EnableProxy('proxyserver:8080') to set a global proxy or you can execute EnableProxy('ftp=ftpproxyserver:2121;gopher=goproxyserver:3333;http=httpproxyserver:8080;https=httpsproxyserver:8080'); you can of course only fill in one of the options like this EnableProxy('http=httpproxyserver:8080'); Well you get the hang of it