This article is actually. It is also fun. Because. Because. Recently, the destiny. So I always like to send time to send time, I suddenly discovered that these places always like to record IP is really trouble. Others Tracing immediately checks your location. It is really unhappy. So. So I have to set up the proxy server .ie is to bring this feature. So it is very simple. As long as the setting is ok. However, I really feel. It's too simple. So I want to do a program. But there is no eyebrow. But I suddenly think of Tencent's browser has a similar function. However, the whole program is only 916K, so it is not necessary to say that there is a dynamic connection library. Since this. So only I will know it. So. So. I use Dumpbin this PE tool IMPORTS to all understand the same thing like other programs. Usually user32, kernel32.gdi32 .... These are not today's protagonist .Wininet.dll is today Lead. Export here. Three functions. The internetsetoption is a key factor. It quickly found in the MSDN. So everything goes well. The key parameters of this function is on the second parameter DWOption. So you will continue to refer to MSDN Internet_option_proxy and Internet_option_settings_changed. The first name also knows that it is set a proxy. The second is responsible for switching settings. OK has this ok. Yes, the basic OK but don't forget this must restart IE. Because IE is also registered. So go to the registration table to find. Soon I understand .Hkey_current_user / software / microsoft / windows / currentversion / Internet settings Almost everyone knows the Internet settings button. Nothing can be said. I know these below. It is simple to implement. Because there is no technology. Just call the API and write registry. First use delphi to implement. Delphi implementation is simple. Because Delphi's unit Wininet encapsulates all documents called by the API, it is more simple. First, do one-to-object-oriented package. An object TsetProxy, then define two data from the proxy host and proxy port. Then a function responsible for calling. The code is as follows: Unit unit1;
Interface
uses Registry, WinInettype TSetProxy = class private {Private declarations} procedure SetReg (FMProxy: string); public {Public declarations} Proxy: string; port: string; constructor Create (Proxy, Port: string); procedure SetProxy (); // procedure SetProxy (const fProxy, fPort: string); end; implementation // set the actual proxy procedure TSetProxy.SetProxy; var FProxy: string; Pinfo: INTERNET_PROXY_INFO; beginFProxy: = Format ( '% s:% s', [self.Proxy , self.port]); Pinfo.dwAccessType: = INTERNET_OPEN_TYPE_PROXY; Pinfo.lpszProxy: = pchar (proxy); InternetSetOption (nil, INTERNET_OPTION_PROXY, @Pinfo, SizeOf (PInfo)); InternetSetOption (nil, INTERNET_OPTION_SETTINGS_CHANGED, nil, 0); SELF.SETREG (FPROXY); END;
// SetReg responsible for reading and writing registry procedure TSetProxy.SetReg (FMProxy: string); varreg: Tregistry; beginreg: = Tregistry.Create; try reg.RootKey: = HKEY_CURRENT_USER; if reg.OpenKey ( '/ Software / Microsoft / Windows / CurrentVersion / Internet Settings', True) then begin reg.Writestring ( 'ProxyServer', FMproxy); reg.WriteInteger ( 'ProxyEnable', integer (true)); end finally reg.CloseKey; reg.free; end; end; constructor TSETPROXY.CREATE (Proxy, Port: String); beginself.proxy: = proxy; self.port: = port; end; end.
Test run is normal.