Bonjour,

Pour poster une requête avec Indy, je dois prendre en compte le proxy.
Pour ça j'utilise le code suivant:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 
var
  ProxyInfo     : PInternetProxyInfo;
  Len           : LongWord;
  ProxyData     : String;
  i, j          : Integer;
  Dts           : TStringDynArray;
  Mchs          : TMatchCollection;
  Cnt: Boolean;
begin
 
  UseProxy  := False;
  HttpPort  := 0;
  FtpPort   := 0;
  HttpsPort := 0;
  SocksPort := 0;
 
  Len := 4096;
  GetMem(ProxyInfo, Len);
  try
    if InternetQueryOption(nil, INTERNET_OPTION_PROXY, ProxyInfo, Len) then
      if ProxyInfo^.dwAccessType = INTERNET_OPEN_TYPE_PROXY then
      begin
        UseProxy  := True;
        ProxyData := string(ProxyInfo^.lpszProxyBypass);
      end
  finally
    FreeMem(ProxyInfo);
  end;
Si les paramètres du proxy sont réglés manuellement sur la machine, dwAccesType renvoie 3 et lpszProxyBypass renvoie une chaîne contenant les infos saisies.
Ca, ça fonctionne très bien.

Par contre, si le proxy est réglé sur détection auto, dwAccesType renvoie 1 et lpszProxyBypass une chaîne vide.

Mais si je ne donne aucune info de proxy, ma requête échoue.

Comment je peux demander à Windows ce qu'il faut renseigner ?
Ou comment faut-il configurer TIdHttp pour que ça fonctionne ?