首页 > 编程语言 > 详细

delphi如何获得当前操作系统语言环境

时间:2015-12-20 22:36:38      阅读:298      评论:0      收藏:0      [点我收藏+]
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 GetWindowsLanguage1(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.Button2Click(Sender: TObject);   
begin 
    Caption := GetWindowsLanguage1(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;

 

delphi如何获得当前操作系统语言环境

原文:http://www.cnblogs.com/findumars/p/5061993.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!