1

I am trying to use Inno Setup for my software. Currently my software is getting over 6000 downloads per day from different Geo. The issue is my software perform differently for each geo, so I have created different exe for each geo. Currently am using the Inno Setup as download manager for my software. Now how can find the user is from which geo and how can I tell my Inno Setup script to download the exe, where is user is from.

Currently what I have now:

#define MyAppName ""
#define MyAppVersion "1"
#define _URL ""
#define _exeFileName "setup.exe"
#include ReadReg(HKEY_LOCAL_MACHINE,'Software\Sherlock Software\InnoTools\Downloader','ScriptPath','');
[Setup]
AppId={{7B0D8E4E-BAFD-400B-B775-0DD7D8FBAE08}
AppName={#MyAppName}
AppVersion={#MyAppVersion};
AppVerName={#MyAppName} {#MyAppVersion}
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
DisableFinishedPage=yes
OutputBaseFilename={#MyAppName}{#MyAppVersion}
Compression=lzma
SolidCompression=yes
DisableWelcomePage=yes
DisableReadyPage=yes
DisableReadyMemo=True
Uninstallable=no
RestartIfNeededByRun=no                     
CreateAppDir=False
UsePreviousGroup=False

If someone can help me out with this will be great.

Thanks in advance

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

1 Answers1

0

I do not know what is the best way to resolve the location. That's for a separate question.

But you can use some online service.

For example the https://ipinfo.io/country

It returns a two-digit ICO country code.

You can use the WinHttpRequest to read the code. See How to read a text file from the Internet resource?


The following example shows how to combine that with the Inno Download Plugin:

var
  Country: string;

function GetCountry: string;
var
  WinHttpReq: Variant;
begin
  if Country <> '' then
  begin
    Log(Format('Using cached country: %s', [Country]));
    Result := Country;
  end
    else
  begin
    try
      WinHttpReq := CreateOleObject('WinHttp.WinHttpRequest.5.1');
      WinHttpReq.Open('GET', 'https://ipinfo.io/country', False);
      WinHttpReq.Send;
      Result := Trim(WinHttpReq.ResponseText);
    except
      Log(GetExceptionMessage);
      Result := 'XX';
    end;

    Country := Result;
    Log(Format('Resolved country: %s', [Country]));
  end;
end;

function InitializeSetup(): Boolean;
begin
  idpAddFile(
    'https://example.com/file-for-' + GetCountry + '.exe',
    ExpandConstant('{tmp}\file.exe'));
end;

Btw, did you consider resolving the geolocation on your site at the download time? And let the user download an installer specific for his/her location directly?

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