Detecting Region

User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

Jeff,

OK, after reading your last message I tried some things and reread all the messages.

I confirm that if I change the Location field to "Canada," the code sample still returns "Uniited States" and when I look in the registry it still says "United States" for the sCountry value. I searched the entire registry for "Canada" and did not find it anywhere (without other text) except in the country code section (it has code of 107). So, it seems that the text stored in the Location field is not directly stored in a place in the registry but the couuntry code may be (I have not searched for 107 which could take quite some time, being that 107 is probably a pretty common occurance).

But, let's dirgress for a moment. It seems you are just wanting to use the Control Panel's Location field as a setup screen for your application? If so, first I would not advise that, and second it may be too difficult (in this case). Why not just have your own setup screen that saves the setup value in the apps own INI file? Wouldn't that solve your problem?

I wouldn't advise changing the Location value because we don't know exactly what other things might be changed when you do that. You don't want to break something else in the process of setting up your application.

James
User avatar
Jeff Barnes
Posts: 912
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada
Contact:

Post by Jeff Barnes »

James,

I can understand what you are saying but here is my situation, maybe someone can suggest another way to solve my problem:

I have written software that will be sold in Canada and Worldwide but there is a part of the program I want to hide from all non-Canadian users due to an agreement with a company in the U.S.

I don't want to have 2 versions of the program so I was hoping to use the windows setup features (like the location field) to enable or disable the option in my program.

I use a software key scheme to protect my program from unauthorized copies ... I allow an evaluation version (basically eval until a valid software key is entered) to be downloaded from my website.

I can easily solve the problem with the software key BUT the end user does not get the key until it is purchased.

So I am back to my problem as to how to hide the option for any non-Canadian customers.

I know someone from outside Canada can easily change their system to say it is from Canada but if they don't know that that is how I am unlocking that option than is should not be an issue.

I hope I am making sense and would gladly accept any ideas as an alternative solution.


Thanks again,

Jeff
Rochinha
Posts: 309
Joined: Sun Jan 08, 2006 10:09 pm
Location: Brasil - Sao Paulo
Contact:

Post by Rochinha »

Just correcting my mistake.

The frase Beil sample's is wrong.

Biel sample's is the correct, thanks for Biel EA6DD and excuse-me.
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

Jeff,

OK, here is your solution. It is a slightly modified version of Rochinha's example. This returns 39 when the Location is "Canada" and something else when it is not (e.g. United States is 244).

By the way, I spent 3 or 4 days in your city a few years ago, and really enjoyed it. What a nice place and nice people too.

James

Code: Select all

# include "fivewin.ch"
#define  HKEY_CURRENT_USER       2147483649

function main()
   msgInfo( NationCode() )
return nil

FUNCTION  NationCode()
   Local oReg, nNation
   oReg := TReg32():New(HKEY_CURRENT_USER, "Control Panel\International\Geo", .f. )
   nNation := oReg:Get( "Nation", '' )
   oReg:Close()
RETURN nNation
User avatar
Biel EA6DD
Posts: 680
Joined: Tue Feb 14, 2006 9:48 am
Location: Mallorca
Contact:

Post by Biel EA6DD »

Don't worry Rochinha :D

The entry Geo, nation like has mentioned James is where you can retrive the Location.
Saludos desde Mallorca
Biel Maimó
http://bielsys.blogspot.com/
User avatar
Jeff Barnes
Posts: 912
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada
Contact:

Post by Jeff Barnes »

Thanks everybody.

James, your solution is exactly what I needed.


[quote]
By the way, I spent 3 or 4 days in your city a few years ago, and really enjoyed it. What a nice place and nice people too.

James
[/quote

When you were up this way it must have been in the summer :wink:
It's -16C today and lots of snow.



Jeff.
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

Jeff,

>James, your solution is exactly what I needed.

Glad to hear it is working for you.

>When you were up this way it must have been in the summer

It was in October, but the weather was great, sunny and warm.

>It's -16C today and lots of snow.

Yikes, -16--that's cold! I figured it must be bad with all the storms that have been there.

Today we are getting what we call a "Santa Anna" which is a East wind from across the desert. Today they are forecasting sunny and temps >20C. Now is a good time to be in San Diego. :-)

Most of my ancestors were French-Canadian from NB. And both my parents are from New England. I am lucky to be here but I do love both New England and Canada (in the summer).

James
Post Reply