function mGetLanguage:string;
var
  mBuf: array[0..255] of char;
begin
  GetLocaleInfo(LOCALE_SYSTEM_DEFAULT,LOCALE_ILANGUAGE,mBuf,256);
  Result:=StrPas(mBuf);
end;

使用示例:ShowMessage(mGetLanguage)

查看winapi.windows

{$EXTERNALSYM GetLocaleInfo}
function GetLocaleInfo(Locale: LCID; LCType: LCTYPE; lpLCData: LPWSTR; cchData: Integer): Integer; stdcall;
{$EXTERNALSYM GetLocaleInfoA}
function GetLocaleInfoA(Locale: LCID; LCType: LCTYPE; lpLCData: LPSTR; cchData: Integer): Integer; stdcall;
{$EXTERNALSYM GetLocaleInfoW}
function GetLocaleInfoW(Locale: LCID; LCType: LCTYPE; lpLCData: LPWSTR; cchData: Integer): Integer; stdcall;

实际引用GetLocaleInfoW函数

https://docs.microsoft.com/zh-cn/windows/desktop/api/winnls/nf-winnls-getlocaleinfow

GetLocaleInfoW function

  • 2018/12/05
  • 2 分钟阅读时长

Retrieves information about a locale specified by identifier.

Note  For interoperability reasons, the application should prefer the GetLocaleInfoEx function to GetLocaleInfo because Microsoft is migrating toward the use of locale names instead of locale identifiers for new locales. Any application that runs only on Windows Vista and later should use GetLocaleInfoEx.

Syntax

C++

int GetLocaleInfoW(LCID   Locale,LCTYPE LCType,LPWSTR lpLCData,int    cchData
);

Parameters

Locale

Locale identifier for which to retrieve information. You can use the MAKELCID macro to create a locale identifier or use one of the following predefined values.

  • LOCALE_CUSTOM_DEFAULT
  • LOCALE_CUSTOM_UI_DEFAULT
  • LOCALE_CUSTOM_UNSPECIFIED
  • LOCALE_INVARIANT
  • LOCALE_SYSTEM_DEFAULT
  • LOCALE_USER_DEFAULT

LCType

The locale information to retrieve. For detailed definitions, see the LCType parameter of GetLocaleInfoEx.

Note  For GetLocaleInfo, the value LOCALE_USE_CP_ACP is relevant only for the ANSI version.

lpLCData

Pointer to a buffer in which this function retrieves the requested locale information. This pointer is not used if cchData is set to 0. For more information, see the Remarks section.

cchData

Size, in TCHAR values, of the data buffer indicated by lpLCData. Alternatively, the application can set this parameter to 0. In this case, the function does not use the lpLCData parameter and returns the required buffer size, including the terminating null character.

Return Value

Returns the number of characters retrieved in the locale data buffer if successful and cchData is a nonzero value. If the function succeeds, cchData is nonzero, and LOCALE_RETURN_NUMBER is specified, the return value is the size of the integer retrieved in the data buffer; that is, 2 for the Unicode version of the function or 4 for the ANSI version. If the function succeeds and the value of cchData is 0, the return value is the required size, in characters including a null character, for the locale data buffer.

The function returns 0 if it does not succeed. To get extended error information, the application can call GetLastError, which can return one of the following error codes:

  • ERROR_INSUFFICIENT_BUFFER. A supplied buffer size was not large enough, or it was incorrectly set to NULL.
  • ERROR_INVALID_FLAGS. The values supplied for flags were not valid.
  • ERROR_INVALID_PARAMETER. Any of the parameter values was invalid.

Remarks

For the operation of this function, see Remarks for GetLocaleInfoEx.

Note   Even when the LCType parameter is specified as LOCALE_FONTSIGNATURE, cchData and the function return are still TCHAR counts. The count is different for the ANSI and Unicode versions of the function. When an application calls the generic version of GetLocaleInfo with LOCALE_FONTSIGNATURE, cchData can be safely specified as sizeof(LOCALESIGNATURE) / sizeof(TCHAR).

The following examples deal correctly with the buffer size for non-text values:

C++

int   ret;
CALID calid;
DWORD value;ret = GetLocaleInfo(LOCALE_USER_DEFAULT,LOCALE_ICALENDARTYPE | LOCALE_RETURN_NUMBER,(LPTSTR)&value,sizeof(value) / sizeof(TCHAR) );
calid = value;LOCALESIGNATURE LocSig;ret = GetLocaleInfo(LOCALE_USER_DEFAULT,LOCALE_FONTSIGNATURE,(LPWSTR)&LocSig,sizeof(LocSig) / sizeof(TCHAR) );

The ANSI string retrieved by the ANSI version of this function is translated from Unicode to ANSI based on the default ANSI code page for the locale identifier. However, if LOCALE_USE_CP_ACP is specified, the translation is based on the system default ANSI code page.

When the ANSI version of this function is used with a Unicode-only locale identifier, the function can succeed because the operating system uses the system code page. However, characters that are undefined in the system code page appear in the string as a question mark (?).

Requirements

   
Minimum supported client Windows 2000 Professional [desktop apps | UWP apps]
Minimum supported server Windows 2000 Server [desktop apps | UWP apps]
Target Platform Windows
Header winnls.h (include Windows.h)
Library Kernel32.lib
DLL Kernel32.dll

GetLocaleInfo获取信息相关推荐

  1. golang微信公众号请求获取信息

    初次用golang在公众号中获取信息,记录一下 看了下文档,粗略的写了个demo,如下: func HttpGet(c*gin.Context) {var param GetTypeif er:=c. ...

  2. android xml获取指定,android:如何从xml文件中获取信息?

    我得到一个程序,从一个链接的服务器获取天气.我已经做了一些将字符串结合到URL的字符串.我现在需要从XML文件中获取信息.android:如何从xml文件中获取信息? 这是我的代码:(我更换了,为了安 ...

  3. js如何获取jwt信息_谈房地产公众号如何涨粉?一篇文章让你轻松获取信息

    原标题:谈房地产公众号如何涨粉?一篇文章让你轻松获取信息 对于房地产企业来说,如何学会运营自己企业的房地产微信公众号是涨粉引流的关键一步,老话说:一步走好,步步稳.值得夸奖的是近几年中高端房地产企业在 ...

  4. linux读取.data文件,[20121227]v$datafile访问是从数据文件获取信息吗.txt

    [20121227]v$datafile访问是从数据文件获取信息吗.txt 记得以前开始学习oracle的时候,被问及访问v$datafile从哪里获取信息,当时想都没想,从数据文件. 虽然当时对方并 ...

  5. uniapp同步获取用户信息_表单设计是为了帮助用户获取信息,而不是填写

    之前有会员来信提到希望能够找一期时间聊一聊在应用中的表单设计,当时我爽快的答应了但却一直没有写. 其实没写的主要原因还是在于网络上已经有了很多关于表单设计的讨论,这些文章都提到了很多在表单设计中需要注 ...

  6. Python从命令行参数和配置文件获取信息

    实际开发中,很多时候需要从外部获取数据,根据用户的输入或配置信息来决定下一步应采取的行为.除了使用内置函数input()或者GUI库的控件和对话框来接收用户输入以外,还可以使用sys和argparse ...

  7. c语言网络定向拉取数据,用C模拟了一个http请求,但是recv函数接收的数据不完整且欠安顺序获取信息...

    用C模拟了一个http请求,但是recv函数接收的数据不完整且不安顺序获取信息 用C模拟了一个http请求,但是recv函数接收的数据不完整且不安顺序获取信息 我把代码贴上 #include #inc ...

  8. JAVA之旅(二十八)——File概述,创建,删除,判断文件存在,创建文件夹,判断是否为文件/文件夹,获取信息,文件列表,文件过滤...

    JAVA之旅(二十八)--File概述,创建,删除,判断文件存在,创建文件夹,判断是否为文件/文件夹,获取信息,文件列表,文件过滤 我们可以继续了,今天说下File 一.File概述 文件的操作是非常 ...

  9. 无法从服务器中获取信息吗,无法从服务器获取信息

    无法从服务器获取信息 内容精选 换一换 查询配额信息.GET /v2/{project_id}/os-quota-sets/{project_id}参数说明参数是否必选参数类型描述project_id ...

最新文章

  1. React 数字取整
  2. HttpURLConnection获取页面源代码乱码问题
  3. 解决sybase数据库的死锁问题
  4. Servlet深入服务之响应response
  5. PyQt5 技术篇-QTableWidget表格组件指定行的隐藏与显示控制实例演示,设置表格指定列的列宽方法
  6. Android studio连接夜神模拟器详细步骤
  7. 启明云端分享|PX30核心板 怎么烧录
  8. 紫外线的形式是什么?
  9. mysql索引的使用及优化方法_MySQL中索引和优化的用法总结
  10. mysql+nest+嵌套事务_MySQL——事务
  11. 通过线程监控socket服务器是否done机
  12. mysql 5.7 root 修改密码_Mysql5.7忘记root密码及mysql5.7修改root密码的方法
  13. 输出判断Codeforces Round #184 (Div. 2)
  14. python爬虫框架scrapy学习图片下载
  15. 几款免费开源的企业管理软件
  16. [贪心][区间dp]Zero-One Codeforces1733D1D2
  17. linux ttl信号处理,TTL和带缓冲的TTL信号(详细)
  18. “胡焕庸”线 - 中国人口分布地理界线
  19. Python爬虫获取网易云歌单封面(带Cookie)
  20. 计算机大赛鼓励语录,比赛前的鼓励的话

热门文章

  1. 网络安全培训课程自学
  2. 连接被远程计算机终结,远程桌面问题终极解决方案
  3. 服务器资源监控工具———node_exporter
  4. python桌面宠物模块_利用python写个桌面挂件 | 手把手带大家做只桌面宠物呗
  5. 汽车的OFF档,ACC档,ON档,START档
  6. 你见过的最难的编程语言是什么?
  7. TDA4VM/VH 芯片 NAVSS0
  8. 计算机网络(树形DP)
  9. 测试员如何推进项目进度?
  10. 百度网盘android 2.0以上,可满速下载的百度云,终于发布手机App(含电脑版/手机版)...