Solved

Get System Language

Posted on 2003-11-06
4
401 Views
Last Modified: 2010-04-05
How can i get the real windows language
That is windows can be english but regional settings is set to turkish.
I want English. (Language of start menu's language), not want regional settings language

Thanx
0
Comment
Question by:mece
  • 2
  • 2
4 Comments
 
LVL 22

Expert Comment

by:Ferruccio Accalai
Comment Utility
procedure TForm1.Button1Click(Sender: TObject);
var
  Ident: Integer;
  MyLang: PChar;
const
  Size: Integer = 250;  
begin
  GetMem(MyLang, Size);
  Ident:=GetSystemDefaultLangID;
  VerLanguageName(Ident, MyLang, Size);
  Label1.Caption:='System language: '+StrPas(MyLang);
  Ident:=GetUserDefaultLangID;
  VerLanguageName(Ident, MyLang, Size);
  Label2.Caption:='User language: '+StrPas(MyLang);
  FreeMem(MyLang);
end;

F68 ;-)
0
 

Author Comment

by:mece
Comment Utility
thanx for answer but that is not what i want
i know this code and this gives the regional settings language
for example my windows is english and i live in turkey, my regional settings set to turkish
above code gives turkish as the asnwer but i want english (windows language)
0
 
LVL 22

Accepted Solution

by:
Ferruccio Accalai earned 125 total points
Comment Utility
Well finally i have understood what you mean...

As i know there a file in System Directory that has this information: Winver.exe (from W95 to WXP).

The way is to read the versioninfo of this file and check for the LanguageID of the file. Look at the following example:

unit Unit1;

interface

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

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

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
   function  GetWinVerLanguage:string;
   var
   Size, Size2 : DWord;
   Pt, Pt2     : Pointer;
   WinFile      : string;
   Syspath,Language: Array[0..255] of char;
   i: Cardinal;
   begin
     getsystemdirectory(SysPath,255);
     WinFile := STrPas(SysPath)+'\winver.exe';
     Result:='No language info available';
     Size := GetFileVersionInfoSize(PChar (winfile), Size2);
     if Size > 0 then
     begin
       GetMem (Pt, Size);
       GetFileVersionInfo (PChar (winfile), 0, Size, Pt);
       VerQueryValue( Pt, '\VarFileInfo\Translation',Pt2, Size2);
       i :=  DWord(Pt2^);
       VerLanguageName(i,Language,255);
       result := STrPas(Language);
     end else
       raise exception.Create ( 'Sorry there are not Language VersionInfo available'+
                                'in Windows.');
   end;
begin
    SHowMessage('Windows language: '+GetWinVerLanguage);
end;
end.

Hope this help.

F68 ;-)
0
 

Author Comment

by:mece
Comment Utility
thanx dude,
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now