2

My installer needs to do some tailoring for users living in United States.

What is the best practice to detect if an end-user is most likely from US?

Will this code work properly so that most Indian and other world-wide people are recognized?

procedure InitializeWizard();
var
  LocaleName : String;
  S : AnsiString;
begin
  if RegQueryStringValue(HKEY_CURRENT_USER, 'Control Panel\International', 'LocaleName', LocaleName) then
  begin
    if (LocaleName = 'en-US') then 
    begin
     // US
    end
    else 
    begin
      // INDIA ETC
    end
  end   
end;
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Tom
  • 6,725
  • 24
  • 95
  • 159
  • 1
    If you are going to read from the Registry, then the `Control Panel\International` key has an `sCountry` value, why not use that instead of the `LocaleName` value? On my machine, `sCountry` says `United States` – Remy Lebeau Sep 20 '22 at 19:22
  • Thanks good idea, however my Win11 device is missing this sCountry value totally... there is iCountry value instead :( Any ideas if the sCountry only was used only in old Windows versions? I need to be compatible with Win7,8,10,11 etc – Tom Sep 21 '22 at 07:05
  • 2
    My machine in Win10, not that old. In any case, if you have `iCountry`, that will work, too. On my machine, `iCountry` is 1, which is `United States` according to [iCountry Registry Values](https://www.robvanderwoude.com/icountry.php) – Remy Lebeau Sep 21 '22 at 15:33
  • 2
    See [Country based download in Inno Setup](https://stackoverflow.com/q/36194647/850848). + You might also consider using [`GetUserDefaultGeoName`](https://learn.microsoft.com/en-us/windows/win32/api/winnls/nf-winnls-getuserdefaultgeoname). – Martin Prikryl Sep 22 '22 at 09:15
  • Thanks, yes IPInfo is good one, but they cost quite much when there are huge amounts of downloads, so I think I will check iCountry option – Tom Sep 22 '22 at 10:54

0 Answers0