How to get OS language using C++ API?

狂风中的少年 提交于 2019-12-18 17:36:31

问题


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)?


回答1:


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.

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

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




回答2:


The accepted answer to this question is wrong. You should not make user interface decisions based on the default locale. Use GetDefaultUILanguage for this.




回答3:


Do you resolve this problem?
If answer is No,
LPWSTR lpLocalName=NULL is wrong.
LPWSTR lpLocalName=NULL ----> WCHAR localName[LOCALE_NAME_MAX_LENGTH] is right. Because No memory allocation is in GetUserDefaultLocalName.



来源:https://stackoverflow.com/questions/2153435/how-to-get-os-language-using-c-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!