How to detect a proxy server for your IE

xiaoxiao2021-03-06  74

/ / ----------------------------------- / / Remember to quote Wininet unit // ------------------------------------------- ---- Useswininet // ------------------------------------------- --- // Define the functions to use // ------------------------------------ -------- function GetProxyInformation: string; var ProxyInfo: PInternetProxyInfo; Len: LongWord; begin Result: = ''; Len: = 4096; GetMem (ProxyInfo, Len); try if InternetQueryOption (nil, INTERNET_OPTION_PROXY, ProxyInfo , Len) then if ProxyInfo ^ .dwAccessType = INTERNET_OPEN_TYPE_PROXY then begin Result: = ProxyInfo ^ .lpszProxy end; finally FreeMem (ProxyInfo); end; end; procedure GetProxyServer (protocol: string; var ProxyServer: string; var ProxyPort: Integer); Var i: integer; proxyInfo, ps: string; begin proxyserver: = '; proxyport: = 0;

Proxyinfo: = getProxyInformation; if proxyInfo = '' TEN EXIT;

Protocol: = protocol '=';

I: = POS (Protocol, Proxyinfo); if i> 0 Then Begin delete (ProxyInfo, 1, i length (protocol)); i: = POS (';', proxyserver); if i> 0 throxyinfo: = Copy (ProxyInfo, 1, I - 1); END;

I: = POS (':', proxyInfo; if i> 0 Then Begin Proxyport: = startdef (copy (ProxyInfo, i 1, Length (ProxyInfo) - i), 0); ProxyServer: = Copy (ProxyInfo, 1 , i - 1) endnd; // --------------------------------------- ----------------------- // Writes / / --------------------- ------------------------------------------ Procedure TFORM1.BUTTON1CLICK (Sender: TObject); var ProxyServer: string; ProxyPort: Integer; begin GetProxyServer ( 'http', ProxyServer, ProxyPort); if ProxyPort = 0 then begin ShowMessage ( 'proxy servers do not use your IE') end else Label1.Caption: = Proxyserver; label2.caption: = INTOSTR (Proxyport);

转载请注明原文地址:https://www.9cbs.com/read-93612.html

New Post(0)