1

Am trying to find out how can I check, if proxy is being used in the computer via Inno Setup.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992

1 Answers1

1

You can use the WinHttpGetDefaultProxyConfiguration function:

type
  WINHTTP_PROXY_INFO = record
    AccessType: Cardinal;
    Proxy: Cardinal;
    ProxyBypass: Cardinal;
  end;

function WinHttpGetDefaultProxyConfiguration(var ProxyInfo: WINHTTP_PROXY_INFO): Boolean;
  external 'WinHttpGetDefaultProxyConfiguration@winhttp.dll stdcall';

function StrCpyN(S1: string; S2: Cardinal; Max: Cardinal): Cardinal;
  external 'StrCpyNW@shlwapi.dll stdcall';

function GetProxy: string;
var
  ProxyInfo: WINHTTP_PROXY_INFO;
begin
  if WinHttpGetDefaultProxyConfiguration(ProxyInfo) then
  begin
    SetLength(Result, 1024);
    StrCpyN(Result, ProxyInfo.Proxy, Length(Result) - 1);
    Result := Trim(Result);
    Log('Retrieved proxy information: ' + Result);
  end
    else
  begin
    Log('Cannot retrieve proxy information');
  end;
end;

Requires Unicode Inno Setup (the only version as of Inno Setup 6).


You can also use netsh winhttp show proxy command.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992