AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Code-Bibliothek Library: Internet / LAN / ASP.NET Delphi Proxy Server Einstellungen des IE abfragen

Proxy Server Einstellungen des IE abfragen

Ein Thema von shmia · begonnen am 8. Apr 2004
Antwort Antwort
shmia

Registriert seit: 2. Mär 2004
5.508 Beiträge
 
Delphi 5 Professional
 
#1

Proxy Server Einstellungen des IE abfragen

  Alt 8. Apr 2004, 11:58
Hallo,

mit den folgenden Funktionen/Proceduren ist es möglich die Proxy Server Einstellungen
des Internet Explorers abzufragen:

Delphi-Quellcode:
unit IEProxy;

interface

uses WinInet, SysUtils, Windows;

type
  TProtocol = (http,
               https,
               ftp,
               gopher,
               socks);

  TProxyInfo = record
    Servername: ShortString;
    Port : word;
  end;

function GetProxyServer(protocol: TProtocol; var ProxyServer: string;
         var ProxyPort: word): Boolean; overload;

function GetProxyServer(protocol: TProtocol;
         var ServerInfo: TProxyInfo): Boolean; overload;

implementation

function ProtocolToString(Protocol: TProtocol): string;
begin
  case Protocol of
    http : Result := 'http';
    https : Result := 'https';
    ftp : Result := 'ftp';
    gopher: Result := 'gopher';
    socks : Result := 'socks';
    else Result := '';
  end;
end;

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;

{**************************************************************************
* NAME:      GetProxyServer
* DESC:      Proxy-Server Einstellungen abfragen
* PARAMS:    protocol => z.B. 'http' oder 'ftp'
* RESULT:    Boolean (Proxy für Protokoll eingetragen)
* CREATED:  08-04-2004/shmia
* MODIFIED:  11-01-2008/DeddyH
*************************************************************************}

function GetProxyServer(protocol: TProtocol; var ProxyServer: string;
         var ProxyPort: word): Boolean;
var
  i : Integer;
  proxyinfo, prot : string;
begin
  Result := false;
  ProxyServer := '';
  ProxyPort := 0;

  proxyinfo := AnsiLowerCase(GetProxyInformation);
  if proxyinfo = 'then
    Exit;

  prot := ProtocolToString(protocol) + '=';

  i := Pos(prot, proxyinfo);
  if i > 0 then
  begin
    Delete(proxyinfo, 1, i + Pred(Length(prot)));
    i := Pos(';', proxyinfo);
    if i > 0 then
      proxyinfo := Copy(proxyinfo, 1, i-1)
    else
      begin
        i := Pos(#32,proxyinfo);
        if i > 0 then
          proxyinfo := Copy(proxyinfo, 1, i-1);
      end;
    Result := true;
  end;

  i := Pos(':', proxyinfo);
  if i > 0 then
    begin
      ProxyPort := StrToIntDef(Copy(proxyinfo, i+1, Length(proxyinfo)-i), 0);
      ProxyServer := Copy(proxyinfo, 1, i-1);
      Result := true;
    end;
end;

function GetProxyServer(protocol: TProtocol; var ServerInfo: TProxyInfo): Boolean;
var s: string;
    i: word;
begin
  Result := GetProxyServer(protocol,s,i);
  ServerInfo.Servername := s;
  ServerInfo.Port := i;
end;

end.
[edit=Matze]Code formatiert. Mfg, Matze[/edit]
[edit=Matze]Überarbeiteten und erweiterten Source-Code von DeddyH eingefügt. MfG, Matze[/edit]
[edit=Matze]Ein "Result" ergänzt. MfG, Matze[/edit]
Andreas
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:31 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz