如何使用 C++ API 获取操作系统语言?

我正在开发一个根据操作系统语言显示对话框的应用程序.如何使用 C++ 或 Windows API (Windows 2008/Vista/7) 获取操作系统语言?

I am in the process of developing a application which displays dialogs depending on the OS language. How I can get the OS language using C++ or Windows APIs (Windows 2008/Vista/7)?

推荐答案

在 Windows 中有几个函数可以做到这一点,具体取决于您想要的信息格式.在 Windows Vista 之前,语言信息被编码为 LCID(Locale Id),包括语言,以及一些关于排序和格式的信息.

There are several functions to do this in Windows, depending on what format you want the information in. Prior to Windows Vista, the language information was encoded into a LCID (Locale Id) which includes language, as well as some information about sorting and formatting.

对于 Windows Vista 和 Windows 7,设计了一个更灵活的系统,称为区域设置名称.GetSystemDefaultLocaleName

For Windows Vista and Windows 7, a more flexible system called Locale Names was devised. GetSystemDefaultLocaleName

如果您想在 Win2k 和 WinXP 上工作,请使用此选项.GetSystemDefaultLCID

Use this if you want to work on Win2k and WinXP. GetSystemDefaultLCID

相关文章