Solved

Get System Language

Posted on 2003-11-06
4
404 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
ID: 9695304
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
ID: 9699497
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
ID: 9723566
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
ID: 9731224
thanx dude,
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

920 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

18 Experts available now in Live!

Get 1:1 Help Now