Am trying to find out how can I check, if proxy is being used in the computer via Inno Setup.
Asked
Active
Viewed 587 times
1
-
What for? The Inno Download Plugin autodetects the proxy on its own, doesn't it? – Martin Prikryl Aug 28 '16 at 08:15
-
Am not sure it does or not but what am trying to do is use it as a trigger for some event inside the scrip so i would like to know how i can display a message if proxy is being used. – Aug 28 '16 at 14:04
-
Also itdownloader is not working when i tried that any idea why? – Aug 31 '16 at 11:56
-
When you tried what? – Martin Prikryl Sep 01 '16 at 07:41
1 Answers
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