Get IE proxy settings

Download source code

procedure TForm1.Button1Click(Sender: TObject);
var
  proxy: PInternetProxyInfo;
  proxyBuf: Pointer;
  proxyBufLen: DWORD;
  b: BOOL;
  s: string;
begin
  proxyBufLen := 4096;
  GetMem(proxyBuf, proxyBufLen);
  try
    b := InternetQueryOption(nil, INTERNET_OPTION_PROXY, proxyBuf, proxyBufLen);
    if not b then raise Exception.Create('Failed to get proxy info');
    proxy := PInternetProxyInfo(proxyBuf);
 
    s := PChar(proxy.lpszProxy);
    //returns for separated settings: 'https=localhost:8081 http=localhost:8080 gopher=localhost:8080 ftp=192.168.19.10:8080 socks=212.12.0.1:1080'
    //returns for http settings only: localhost:8080
    //returns for https settings only: https=localhost:8081
    //returns empty string if no proxy selected
    //returns empty string if autoproxy or proxy.pac specified
 
    Memo1.Lines.Delimiter := #32;
    Memo1.Lines.DelimitedText := s;
 
    ShowMessage('Done');
  finally
    FreeMem(proxyBuf);
  end;
end;

Add Feedback