Detecting Region
- Jeff Barnes
- Posts: 912
- Joined: Sun Oct 09, 2005 1:05 pm
- Location: Ontario, Canada
- Contact:
Detecting Region
Hi Everybody,
How can I detect what region a computer is set up for (Canada, United States etc...)
Thanks,
Jeff
How can I detect what region a computer is set up for (Canada, United States etc...)
Thanks,
Jeff
Get region
Hi Jeff,
Try GetLocaleInfoA: the format is below
DLL32 FUNCTION GetLocInfoA;
( Locale AS LONG, ;
LCType AS LONG, ;
lpLCData AS STRING, ;
cchData AS LONG ) ;
AS LONG PASCAL;
FROM "GetLocaleInfoA" LIB "KERNEL32"
The CONSTANTs for passing are
CONSTANT long LOCALE_ICOUNTRY = 5 ' Country code, based on international phone codes
CONSTANT long LOCALE_SCOUNTRY = 6 ' The full localized name of the country.
CONSTANT long LOCALE_SENGCOUNTRY = 4098 ' The full English U.S. name of the country.
CONSTANT long LOCALE_SABBREVCTRYNAME = 7 ' Abbreviated name of the country ISO Standard 3166.
CONSTANT long LOCALE_SNATIVECTRYNAME = 8 ' Native name of the country.
eg.
LOCAL ls_str
ls_str = space(128)
GetLocInfoA( GetSystemDefaultLCID(), LOCALE_SXXX, ls_str,128)
Try GetLocaleInfoA: the format is below
DLL32 FUNCTION GetLocInfoA;
( Locale AS LONG, ;
LCType AS LONG, ;
lpLCData AS STRING, ;
cchData AS LONG ) ;
AS LONG PASCAL;
FROM "GetLocaleInfoA" LIB "KERNEL32"
The CONSTANTs for passing are
CONSTANT long LOCALE_ICOUNTRY = 5 ' Country code, based on international phone codes
CONSTANT long LOCALE_SCOUNTRY = 6 ' The full localized name of the country.
CONSTANT long LOCALE_SENGCOUNTRY = 4098 ' The full English U.S. name of the country.
CONSTANT long LOCALE_SABBREVCTRYNAME = 7 ' Abbreviated name of the country ISO Standard 3166.
CONSTANT long LOCALE_SNATIVECTRYNAME = 8 ' Native name of the country.
eg.
LOCAL ls_str
ls_str = space(128)
GetLocInfoA( GetSystemDefaultLCID(), LOCALE_SXXX, ls_str,128)
Richard Grayden
Sydney,
NSW Australia
Sydney,
NSW Australia
- Jeff Barnes
- Posts: 912
- Joined: Sun Oct 09, 2005 1:05 pm
- Location: Ontario, Canada
- Contact:
Oops!
DLL32 FUNCTION GetSystemDefaultLCID();
AS LONG PASCAL;
FROM "GetSystemDefaultLCID" LIB "KERNEL32"
try this
# include "fivewin.ch"
# define LOCALE_ICOUNTRY 5
# define LOCALE_SCOUNTRY 6
# define LOCALE_SENGCOUNTRY 4098
# define LOCALE_SABBREVCTRYNAME 7
FUNCTION Main()
LOCAL strCountry := Space(128)
GetLocInfoA( GetSystemDefaultLCID(), LOCALE_SENGCOUNTRY, @strCountry,128)
MsgInfo(strCountry)
RETURN NIL
DLL32 FUNCTION GetLocInfoA;
( Locale AS LONG, ;
LCType AS LONG, ;
lpLCData AS STRING, ;
cchData AS LONG ) ;
AS LONG PASCAL;
FROM "GetLocaleInfoA" LIB "KERNEL32"
DLL32 FUNCTION GetSystemDefaultLCID();
AS LONG PASCAL;
FROM "GetSystemDefaultLCID" LIB "KERNEL32"
DLL32 FUNCTION GetSystemDefaultLCID();
AS LONG PASCAL;
FROM "GetSystemDefaultLCID" LIB "KERNEL32"
try this
# include "fivewin.ch"
# define LOCALE_ICOUNTRY 5
# define LOCALE_SCOUNTRY 6
# define LOCALE_SENGCOUNTRY 4098
# define LOCALE_SABBREVCTRYNAME 7
FUNCTION Main()
LOCAL strCountry := Space(128)
GetLocInfoA( GetSystemDefaultLCID(), LOCALE_SENGCOUNTRY, @strCountry,128)
MsgInfo(strCountry)
RETURN NIL
DLL32 FUNCTION GetLocInfoA;
( Locale AS LONG, ;
LCType AS LONG, ;
lpLCData AS STRING, ;
cchData AS LONG ) ;
AS LONG PASCAL;
FROM "GetLocaleInfoA" LIB "KERNEL32"
DLL32 FUNCTION GetSystemDefaultLCID();
AS LONG PASCAL;
FROM "GetSystemDefaultLCID" LIB "KERNEL32"
Richard Grayden
Sydney,
NSW Australia
Sydney,
NSW Australia
- Jeff Barnes
- Posts: 912
- Joined: Sun Oct 09, 2005 1:05 pm
- Location: Ontario, Canada
- Contact:
- Biel EA6DD
- Posts: 680
- Joined: Tue Feb 14, 2006 9:48 am
- Location: Mallorca
- Contact:
Return Country assigned in Regional Settings.
Regards from Mallorca Is.
Code: Select all
# include "fivewin.ch"
#define HKEY_CURRENT_USER 2147483649
FUNCTION Main()
Local oReg, cCountry
oReg := TReg32():New(HKEY_CURRENT_USER, "Control Panel\International", .f. )
cCountry := oReg:Get( "sCountry", '' )
MsgInfo(cCountry)
oReg:Close()
RETURN NIL
- Jeff Barnes
- Posts: 912
- Joined: Sun Oct 09, 2005 1:05 pm
- Location: Ontario, Canada
- Contact:
Oh so close ....
Now it will select the
[img]
http://www.can-soft.net/dl/Region.JPG
[/img]
It is selecting the country based on the language setting (see item 1 in screen shot)
Is it possible to get the info stored in "location" (see item 2 in screen shot)
I really appreciate the help.
Thanks,
Jeff
Now it will select the
[img]
http://www.can-soft.net/dl/Region.JPG
[/img]
It is selecting the country based on the language setting (see item 1 in screen shot)
Is it possible to get the info stored in "location" (see item 2 in screen shot)
I really appreciate the help.
Thanks,
Jeff
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Jeff,
If I understand what you are saying, you are getting back "English (Canada)" instead of "Canada"?
Here I am getting what is in the location field (for me that is "United States"). My "Standards and Formats" field shows "English (United States)" in the Control Panel. I am using XP Pro SPII.
So, it is working correctly for me.
James
If I understand what you are saying, you are getting back "English (Canada)" instead of "Canada"?
Here I am getting what is in the location field (for me that is "United States"). My "Standards and Formats" field shows "English (United States)" in the Control Panel. I am using XP Pro SPII.
So, it is working correctly for me.
James
Jeff
look this modification in the Beil sample's:
This retrieve for me, 55, integer, Brazil.
look this modification in the Beil sample's:
Code: Select all
# include "fivewin.ch"
#define HKEY_CURRENT_USER 2147483649
FUNCTION CountryArea()
Local oReg, nCountry
oReg := TReg32():New(HKEY_CURRENT_USER, "Control Panel\International", .f. )
nCountry := oReg:Get( "iCountry", '' )
MsgInfo(cCountry)
oReg:Close()
RETURN nCountry
- Jeff Barnes
- Posts: 912
- Joined: Sun Oct 09, 2005 1:05 pm
- Location: Ontario, Canada
- Contact:
James.
My mistake ... I was thinking one thing and typing another.
What I get back is "Canada" based on the setting "English (Canada)"
What I would like to do is get the "Location" value and use that instead of using what we currently are getting with Beil's sample.
Do you know if this is possible?
Thanks,
Jeff
My mistake ... I was thinking one thing and typing another.
What I get back is "Canada" based on the setting "English (Canada)"
What I would like to do is get the "Location" value and use that instead of using what we currently are getting with Beil's sample.
Do you know if this is possible?
Thanks,
Jeff
- Jeff Barnes
- Posts: 912
- Joined: Sun Oct 09, 2005 1:05 pm
- Location: Ontario, Canada
- Contact:
Richard,
I have tried.
No matter what I have set on my computer in the regional settings, when I try your sample it always returns "United States"
What I am looking for is the value that is stored for the "Location" field at the bottom of the "Regional and Language Options" window, under the "Regional Options" tab.
Thanks,
Jeff
I have tried.
No matter what I have set on my computer in the regional settings, when I try your sample it always returns "United States"
Code: Select all
# include "fivewin.ch"
# define LOCALE_ICOUNTRY 5
# define LOCALE_SCOUNTRY 6
# define LOCALE_SENGCOUNTRY 4098
# define LOCALE_SABBREVCTRYNAME 7
FUNCTION Main()
LOCAL strCountry := Space(128)
GetLocInfoA( GetSystemDefaultLCID(), LOCALE_SENGCOUNTRY, @strCountry,128)
MsgInfo(strCountry)
RETURN NIL
DLL32 FUNCTION GetLocInfoA;
( Locale AS LONG, ;
LCType AS LONG, ;
lpLCData AS STRING, ;
cchData AS LONG ) ;
AS LONG PASCAL;
FROM "GetLocaleInfoA" LIB "KERNEL32"
DLL32 FUNCTION GetSystemDefaultLCID();
AS LONG PASCAL;
FROM "GetSystemDefaultLCID" LIB "KERNEL32"
Thanks,
Jeff
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Jeff,
OK, I am not clear on exactly what you want. You want some kind of ID number corresponding to the text that is in the Location field? Does that number have some significance to you?
Did you try Rochinha's solution? With a slight bug fix (change cCountry to nCountry) it does return a number value. It returns 1 for me which seems to be the country code (for USA) used in international phone numbers. I don't know if it is number you want.
James
OK, I am not clear on exactly what you want. You want some kind of ID number corresponding to the text that is in the Location field? Does that number have some significance to you?
Did you try Rochinha's solution? With a slight bug fix (change cCountry to nCountry) it does return a number value. It returns 1 for me which seems to be the country code (for USA) used in international phone numbers. I don't know if it is number you want.
James
- Jeff Barnes
- Posts: 912
- Joined: Sun Oct 09, 2005 1:05 pm
- Location: Ontario, Canada
- Contact:
James,
Actually, all I want is to grab the text that is stored in the filed called "Location" in the Regional Options tab.
I want to use this to enable an option in my app that is only available to the Canadian market.
I don't want the user to have to change the main setting as one of our medical systems (software not written by myself) needs this to be set to "English (United States)" or it causes issues. So, I thought if I could change the "Location" to "Canada" (in Windows Regional Options) and grab that value it would solve my problem.
I hope this makes things a bit clearer
Jeff
Actually, all I want is to grab the text that is stored in the filed called "Location" in the Regional Options tab.
I want to use this to enable an option in my app that is only available to the Canadian market.
I don't want the user to have to change the main setting as one of our medical systems (software not written by myself) needs this to be set to "English (United States)" or it causes issues. So, I thought if I could change the "Location" to "Canada" (in Windows Regional Options) and grab that value it would solve my problem.
I hope this makes things a bit clearer
Jeff