whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1547)

Database (90)
Files (137)
Forms (107)
Graphic (115)
IDE (21)
Indy (5)
Internet / LAN (131)
IntraWeb (0)
Math (76)
Misc (127)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (268)
VCL (243)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

44 Visitors Online


 
...get the systems default language?
Autor: Thomas Stutz
[ Print tip ]  

Tip Rating (16):  
     


function GetWindowsLanguage: string;
var
  
WinLanguage: array [0..50] of char;
begin
  
VerLanguageName(GetSystemDefaultLangID, WinLanguage, 50);
  Result := StrPas(WinLanguage);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  
ShowMessage(GetWindowsLanguage);
end;

{********************************************************************}
{ another code:
{********************************************************************}

function GetWindowsLanguage(LCTYPE: LCTYPE {type of information}): string;
var
  
Buffer : PChar;
  Size : integer;
begin
  
Size := GetLocaleInfo (LOCALE_USER_DEFAULT, LCType, nil, 0);
  GetMem(Buffer, Size);
  try
    
GetLocaleInfo (LOCALE_USER_DEFAULT, LCTYPE, Buffer, Size);
    Result := string(Buffer);
  finally
    
FreeMem(Buffer);
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  
Caption := GetWindowsLanguage(LOCALE_SABBREVLANGNAME);
 (*
  LOCALE_ILANGUAGE           { language id }
  LOCALE_SLANGUAGE           { localized name of language }
  LOCALE_SENGLANGUAGE        { English name of language }
  LOCALE_SABBREVLANGNAME     { abbreviated language name }
  LOCALE_SNATIVELANGNAME     { native name of language }
 *)
end;

 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners