News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

How to get Country?

Started by RHL, January 13, 2012, 06:01:47 AM

Previous topic - Next topic

RHL

Hello! :)
Anyone know how to get the country of the PC? :)
what api?
Very thanks :)

donkey

GetLocaleInfo using LOCALE_ICOUNTRY

For example:

invoke GetLocaleInfo,LOCALE_USER_DEFAULT,LOCALE_ICOUNTRY,offset lccode,16

Note that the code is output as a string (Max 6 characters). Since I live in Canada I get country code 2 (CTRY_CANADA). The country codes are defined as follows in WinNLS.h

#define CTRY_DEFAULT  0
#define CTRY_ALBANIA  355
#define CTRY_ALGERIA  213
#define CTRY_ARGENTINA  54
#define CTRY_AUSTRALIA  61
#define CTRY_AUSTRIA  43
#define CTRY_BAHRAIN  973
#define CTRY_BELARUS  375
#define CTRY_BELGIUM  32
#define CTRY_BELIZE  501
#define CTRY_BOLIVIA  591
#define CTRY_BRAZIL  55
#define CTRY_BRUNEI_DARUSSALAM  673
#define CTRY_BULGARIA  359
#define CTRY_CANADA  2
#define CTRY_CARIBBEAN  1
#define CTRY_CHILE  56
#define CTRY_COLOMBIA  57
#define CTRY_COSTA_RICA  506
#define CTRY_CROATIA  385
#define CTRY_CZECH  420
#define CTRY_DENMARK  45
#define CTRY_DOMINICAN_REPUBLIC  1
#define CTRY_ECUADOR  593
#define CTRY_EGYPT  20
#define CTRY_EL_SALVADOR  503
#define CTRY_ESTONIA  372
#define CTRY_FAEROE_ISLANDS  298
#define CTRY_FINLAND  358
#define CTRY_FRANCE  33
#define CTRY_GERMANY  49
#define CTRY_GREECE  30
#define CTRY_GUATEMALA  502
#define CTRY_HONDURAS  504
#define CTRY_HONG_KONG  852
#define CTRY_HUNGARY  36
#define CTRY_ICELAND  354
#define CTRY_INDIA  91
#define CTRY_INDONESIA  62
#define CTRY_IRAN  981
#define CTRY_IRAQ  964
#define CTRY_IRELAND  353
#define CTRY_ISRAEL  972
#define CTRY_ITALY  39
#define CTRY_JAMAICA  1
#define CTRY_JAPAN  81
#define CTRY_JORDAN  962
#define CTRY_KENYA  254
#define CTRY_KUWAIT  965
#define CTRY_LATVIA  371
#define CTRY_LEBANON  961
#define CTRY_LIBYA  218
#define CTRY_LIECHTENSTEIN  41
#define CTRY_LITHUANIA  370
#define CTRY_LUXEMBOURG  352
#define CTRY_MACAU  853
#define CTRY_MACEDONIA  389
#define CTRY_MALAYSIA  60
#define CTRY_MEXICO  52
#define CTRY_MONACO  33
#define CTRY_MOROCCO  212
#define CTRY_NETHERLANDS  31
#define CTRY_NEW_ZEALAND  64
#define CTRY_NICARAGUA  505
#define CTRY_NORWAY  47
#define CTRY_OMAN  968
#define CTRY_PAKISTAN  92
#define CTRY_PANAMA  507
#define CTRY_PARAGUAY  595
#define CTRY_PERU  51
#define CTRY_PHILIPPINES  63
#define CTRY_POLAND  48
#define CTRY_PORTUGAL  351
#define CTRY_PRCHINA  86
#define CTRY_PUERTO_RICO  1
#define CTRY_QATAR  974
#define CTRY_ROMANIA  40
#define CTRY_RUSSIA  7
#define CTRY_SAUDI_ARABIA  966
#define CTRY_SERBIA  381
#define CTRY_SINGAPORE  65
#define CTRY_SLOVAK  421
#define CTRY_SLOVENIA  386
#define CTRY_SOUTH_AFRICA  27
#define CTRY_SOUTH_KOREA  82
#define CTRY_SPAIN  34
#define CTRY_SWEDEN  46
#define CTRY_SWITZERLAND  41
#define CTRY_SYRIA  963
#define CTRY_TAIWAN  886
#define CTRY_THAILAND  66
#define CTRY_TRINIDAD_Y_TOBAGO  1
#define CTRY_TUNISIA  216
#define CTRY_TURKEY  90
#define CTRY_UAE  971
#define CTRY_UKRAINE  380
#define CTRY_UNITED_KINGDOM  44
#define CTRY_UNITED_STATES  1
#define CTRY_URUGUAY  598
#define CTRY_VENEZUELA  58
#define CTRY_VIET_NAM  84
#define CTRY_YEMEN  967
#define CTRY_ZIMBABWE  263
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

RHL

 :clap:
Very Thanks donkey :)

donkey

No Probs RHL,

If you'd like the country as a string (eg "Canada") you can use:

invoke GetLocaleInfo,LOCALE_USER_DEFAULT,LOCALE_SCOUNTRY ,offset CntryString,80

The maximum length of the string is 80 characters. LOCALE_SCOUNTRY is listed as deprecated in Windows 7 however I have tested it and it works fine in Win7.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

RHL

worked  :bg I also tested on win 7 

donkey

Quote from: RHL on January 13, 2012, 07:13:53 AM
worked  :bg I also tested on win 7 

Yes, both 32 and 64 bit versions.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable