How to detect in which country / region installer is running (offline).
13 Answers
There's GetUserDefaultGeoName function:
[Code]
function GetUserDefaultGeoName(GeoName: string; GeoNameCount: Integer): Integer; external '[email protected] stdcall';
function GetGeoName: string;
begin SetLength(Result, 100); SetLength(Result, GetUserDefaultGeoName(Result, Length(Result)));
end; You should access registry key HKEY_CURRENT_USER/Control Panel/International/sCountry or possibly sLanguage.
Note this will give you the cultural conventions and language the user wants rather the actual geographical location.
A possible alternative is HKEY_CURRENT_USER/Software/Microsoft/Windows NT/TimeZones/TimeZoneKeyName which may give you a clue as to the real location.
Otherwise you could use a web service like which will tell you the location of the machines ISP, which may well be in a different country from the machine itself given the tortured topology of some corporate networks.
What usually works best is to ask the user to "Select Country" from a pull-down menu.
2You should not rely on registry values, they might be changed or removed from later version of Windows without further notice. I recommend to use Windows API GetLocaleInfo() directly instead.
BTW, why do you want to do that? If you just want to make your installer automatically use a language corresponds to the language settings in the user's control panel, set LanguageDetectionMethod=locale in the [Setup] section.