Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Delphi GetProxyInformation unter Delphi 2009 (https://www.delphipraxis.net/131010-getproxyinformation-unter-delphi-2009-a.html)

DeddyH 17. Mär 2009 16:40

Re: GetProxyInformation unter Delphi 2009
 
Macht es denn dann Sinn, die Unicode-Version von InternetQueryOption aufzurufen, um dann doch Ansi-Strings zurückzubekommen? Dann könnte man auch gleich InternetQueryOptionA verwenden, oder habe ich gerade einen Knick im Hirn?

GPRSNerd 17. Mär 2009 16:45

Re: GetProxyInformation unter Delphi 2009
 
Hast natürlich recht, aber die Variante mit InternetQueryOption funktioniert so nicht, da das standardmäßig die Widestring-Variante ist.
Man muss den Code also explizit auf Ansi umstellen, also nicht nur InternetQueryOptionA, sondern auch PInternetProxyInfoA:

Delphi-Quellcode:
function GetProxyInformation: AnsiString;
var
  ProxyInfo: PInternetProxyInfoA;
  Len: LongWord;
begin
  Result := '';
  Len := 4096;
  GetMem(ProxyInfo, Len);
  try
    if InternetQueryOptionA(nil, INTERNET_OPTION_PROXY, ProxyInfo, Len) then
    begin
      if ProxyInfo^.dwAccessType = INTERNET_OPEN_TYPE_PROXY then
      begin
        Result := ProxyInfo^.lpszProxy;
      end;
    end;
  finally
    FreeMem(ProxyInfo);
  end;
end;

DeddyH 17. Mär 2009 16:46

Re: GetProxyInformation unter Delphi 2009
 
OK, das ist einzusehen.

GPRSNerd 17. Mär 2009 21:01

Re: GetProxyInformation unter Delphi 2009
 
Nochmal zur Vervollständigung:

In meiner Windows.pas (Delphi 2009, Update 2) ist LPCTSTR folgendermaßen definiert:

Delphi-Quellcode:
LPCTSTR = {$IFDEF UNICODE}PWideChar{$ELSE}PAnsiChar{$ENDIF};
Das sollte also eigentlich sowohl mit D2007, als auch mit D2009 funktionieren.
Tuts aber leider nicht, da bei Benutzen von PWideChars und InternetQueryOptionW das oben beschriebene Problem auftritt und unter D2009 nur Müll zurückgegeben wird. Der Fehler muss also noch irgendwo anders sein, aber egal, da mir die Ansi-Variante ausreicht.

GPRSNerd 18. Mär 2009 09:47

Re: GetProxyInformation unter Delphi 2009
 
Ich habe mal einen Report in Quality Central für die UNICODE-Variante unter Delphi 2009 erstellt, zu finden unter:
http://qc.embarcadero.com/wc/qcmain.aspx?d=72305

GPRSNerd 18. Sep 2009 12:31

Re: GetProxyInformation unter Delphi 2009
 
Der Issue wurde (angeblich) in D2010 gefixt:

Resolution Full Name Date Changed Build
Fixed QC<->Raid Replicator Account 8/27/2009 5:14:37 PM 14.0.3448.21948
Comment: Status pulled automatically from the internal system

Muss ich mal ausprobieren, wenn ich auf D2010 upgrade...


Alle Zeitangaben in WEZ +1. Es ist jetzt 20:37 Uhr.
Seite 2 von 2     12   

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