Solved

Get Country Info from Regional Settings

Posted on 1999-11-10
7
2,718 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: 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 50 total points
ID: 2204417
Oh Great! Thanks,

Cheers,
Phil.
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

726 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