Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Get Country Info from Regional Settings

Posted on 1999-11-10
7
Medium Priority
?
2,769 Views
Last Modified: 2008-02-26
I would like to get the Country Information from the Regional Settings. Either some Delphi 4 or 5 code or a component would be appreciated.
0
Comment
Question by:skymag
7 Comments
 
LVL 7

Expert Comment

by:RBertora
ID: 2196712
There is no country setting in the regional settings... only Language, but if that is what you want you can probably work things out from this piece of code:

Rob ;-)

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(inttostr(GetUserDefaultLangID));




  case GetUserDefaultLangID of

(*  for some unknown reason these do not work!!!aargg
    LANG_AFRIKAANS : label1.Caption := 'AFRIKAANS';
    LANG_ICELANDIC : label1.Caption := 'ICELANDIC';
    LANG_ALBANIAN : label1.Caption := 'ALBANIAN';
    LANG_INDONESIAN : label1.Caption := 'INDONESIAN';
    LANG_ARABIC : label1.Caption := 'ARABIC';
    LANG_ITALIAN : label1.Caption := 'ITALIAN';
    LANG_BASQUE : label1.Caption := 'BASQUE';
    LANG_JAPANESE : label1.Caption := 'JAPANESE';
    LANG_BELARUSIAN : label1.Caption := 'BELARUSIAN';
    LANG_KOREAN : label1.Caption := 'KOREAN';
    LANG_BULGARIAN : label1.Caption := 'BULGARIAN';
    LANG_LATVIAN : label1.Caption := 'LATVIAN';
    LANG_CATALAN : label1.Caption := 'CATALAN';
    LANG_LITHUANIAN : label1.Caption := 'LITHUANIAN';
    LANG_CHINESE : label1.Caption := 'CHINESE';
    LANG_NEUTRAL : label1.Caption := 'NEUTRAL';
    LANG_CROATIAN : label1.Caption := 'CROATIAN';
    LANG_NORWEGIAN : label1.Caption := 'NORWEGIAN';
    LANG_CZECH : label1.Caption := 'CZECH';
    LANG_POLISH : label1.Caption := 'POLISH';
    LANG_DANISH : label1.Caption := 'DANISH';
    LANG_PORTUGUESE : label1.Caption := 'PORTUGUESE';
    LANG_DUTCH : label1.Caption := 'DUTCH';
    LANG_ROMANIAN : label1.Caption := 'ROMANIAN';
    LANG_ENGLISH : label1.Caption := 'ENGLISH';
    LANG_RUSSIAN : label1.Caption := 'USSIAN';
    LANG_ESTONIAN : label1.Caption := 'ESTONIAN';
    LANG_FAEROESE : label1.Caption := 'FAEROESE';
    LANG_SLOVAK : label1.Caption := 'SLOVAK';
    LANG_FARSI : label1.Caption := 'FARSI';
    LANG_SLOVENIAN : label1.Caption := 'SLOVENIAN';
    LANG_FINNISH : label1.Caption := 'FINNISH';
    LANG_SPANISH : label1.Caption := 'SPANISH';
    LANG_FRENCH : label1.Caption := 'FRENCH';
    LANG_SWEDISH : label1.Caption := 'SWEDISH';
    LANG_GERMAN : label1.Caption := 'GERMAN';
    LANG_THAI : label1.Caption := 'THAI';
    LANG_GREEK : label1.Caption := 'GREEK';
    LANG_TURKISH : label1.Caption := 'TURKISH';
    LANG_HEBREW : label1.Caption := 'HEBREW';
    LANG_HUNGARIAN : label1.Caption := 'HUNGARIAN';
    LANG_VIETNAMESE : label1.Caption := 'VIETNAMESE';
*)

    2057 : Label1.Caption := 'English United Kingdom';
    1078 : Label1.Caption := 'Afrikaans';
// I got these values by changing the settings and then clicking the button
// to get the constant values.. you can do the same for all the languages..
// what a grind..

  end;
end;

end.
0
 
LVL 10

Expert Comment

by:Lischke
ID: 2197260
Rob,

of course your case statement works if you consider one point :-) The language ID contains in reality two values: the primary language and the sub language. Look also MakeLangID and channge your statement to:

  case GetUserDefaultLangID and $3FF of

then it works.

skymag,

what information are you interested in? I think Rob is right if you need the country of the system (if one can say this so). By retrieving the system or user language you get the country too. Do you need anything else?

Ciao, Mike
0
 
LVL 7

Expert Comment

by:RBertora
ID: 2197285
ah, I had considered that but must admit wasn't driven to explore it further.. Thanks for the info Mike.
Rob ;-)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:philipleighs
ID: 2197944
Here is some code that returns a string like "New Zealand (English)":

function TInfoComputer.GetLocale(ALcid: Integer): string;
  var s: string;
  begin
    Result := '[Unknown]';
    SetLength(s, 128);
    if GetLocaleInfo(ALcid, LOCALE_SENGLANGUAGE, PChar(s), 128) > 0 then
      begin
        Result := StrPas(PChar(s));
        if GetLocaleInfo(ALcid, LOCALE_SENGCOUNTRY, PChar(s), 128) > 0 then
          begin
            Result := Format('%s (%s)', [Result, StrPas(PChar(s))]);
          end;
      end;
  end;

Cheers,
Phil.
0
 
LVL 7

Expert Comment

by:RBertora
ID: 2200240
Nice function Phil!

  showmessage(GetLocale(GetUserDefaultLangID));

points should be yours :-)

Rob;-)
0
 

Author Comment

by:skymag
ID: 2202228
Thanx for all the input guys!

Phil, can you lock the question so that I can assign the points to you!
0
 
LVL 3

Accepted Solution

by:
philipleighs earned 200 total points
ID: 2204417
Oh Great! Thanks,

Cheers,
Phil.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question