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
  • 167,268
  • 50
  • 405
  • 846
  • That's a pretty broad question. You actually have two questions here. The first is how to find the country the user is in. And the second is how to use that information in Inno Setup. Ask these question separately. – Martin Prikryl Mar 24 '16 at 07:04
  • Thank you for your instant reply on my question, i really appreciate that you are giving your precious time for every users question on your expert boundary... –  Mar 24 '16 at 07:37
  • @MartinPrikryl would be really happy if you can teach me or guide me how i can find the user location in Inno setup using the Geolocation or the Ip address of the user( An accurate Location ) please help me how i can do that note : One of my friend is using http send request but he is not willing to share it Thank you in advance –  Mar 24 '16 at 07:39
  • Also if any other experts in this blog please help me out how to send them to that particular Geo exe in inno-Setup. –  Mar 24 '16 at 07:42

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
  • 167,268
  • 50
  • 405
  • 846
  • thank you so much, its works awesome and i did try to do that but this seems to be easier than that also i can learn new tricks in inno. –  Mar 24 '16 at 09:33
  • You are welcome. Though on StackOverflow we [thank by accepting the answer](http://stackoverflow.com/help/someone-answers). – Martin Prikryl Mar 24 '16 at 09:48
  • Sorry for the delay in reply, Yes your answer helped also i had some of my own edits and made it work but one issue am facing with the VPN downloads and How can i detect the VPN users and send them to their original download location @MartinPrikryl –  Jul 17 '16 at 08:27
  • Thank you very much for answering the previous question, Yes your answer helped me with the last question i have posted. @MartinPrikryl –  Jul 18 '16 at 06:14
  • @Baskarkumar I do not see what does your problem have to do with this question. Please delete your comments, and post a proper question. – Martin Prikryl Jan 11 '19 at 15:40