开发者

How to get OS language using C++ API?

开发者 https://www.devze.com 2022-12-18 04:09 出处:网络
I am in the process of developing a application which displays dialogs depending on the OS language. How I can get the OS langua开发者_运维知识库ge using C++ or Windows APIs (Windows 2008/Vista/7)?The

I am in the process of developing a application which displays dialogs depending on the OS language. How I can get the OS langua开发者_运维知识库ge using C++ or Windows APIs (Windows 2008/Vista/7)?


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


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号