tags:

views:

48

answers:

3

how to detect in which country / region installer is running (offline)

A: 

Make a unique HTTP Get request to your server while installing and from header detect its IP and from that resolve it to location.

provided that user is online

org.life.java
I am looking for Win api solution (offline)
Tom
retag your question
org.life.java
A: 

You should access registry key 'H_KEY_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 loacation.

A possible alternative is 'H_KEY_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 'http://www.ip-adress.com/' 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 topoloigy of some corporate networks.

What usually works best is to ask the user to "Select Country" from a pulldown menu.

James Anderson
Nothing stored on the system will give the country / region - the computer doesn't have to be in the place where it was installed. A tracking device (using GPS or similar) would be the only way to get this information reliably.
mghie
I totally aggree. There are two reasons to get this data. One to set the right language etc. in which case the registry keys are what you want, the other is for licensing or other contractual/legal reasons where the best (but still not 100%) method is to send a license key via registered snail mail.
James Anderson
A: 

You 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.

Vantomex