Reputation: 2112
I've been searching msdn forever now without a straight answer.
Is there a way to simply get the user's language? I don't want to load any resources or anything at this point, I just want to get their language. Is there ANY simple way to do this?
I'm using visual C++,and I'm not using MFC or anything like that.
Upvotes: 1
Views: 4472
Reputation: 336
Here is the way by calling below API.
LCID lcinfo = GetUserDefaultLCID();
The GetUserDefaultLCID function retrieves the user default locale identifier. On single-user systems, the return value is the same as that returned by GetSystemDefaultLCID.
LCID is the Win32 locale identifier of 32-bit value, combining language and sorting identifiers with predefined locale identifiers are.
LOCALE_SYSTEM_DEFAULT :- which identifies the system default locale; on later versions of Windows, it can be changed via the Control Panel's Default Language setting.
LOCALE_USER_DEFAULT :- which identifies the locale of the current user; it can be changed via the Control Panel default locale setting.
An application can retrieve these two predefined locale identifiers by calling the GetSystemDefaultLCID() and GetUserDefaultLCID() functions, respectively. While, The Thread Locale is maintained on application thread basis and uses SetThreadLocale() and GetThreadLocale() to access the value.
Note: Initially, the value of the thread locale is set to the value of the user's default locale.
Upvotes: 0
Reputation: 72638
GetUserDefaultLCID or GetUserDefaultLocaleName on Vista will return the LCID/locale name of the user's default locale.
You can then use GetLocaleInfo or GetLocaleInfoEx on Vista to get the display name of the locale (either LOCALE_SENGLISHDISPLAYNAME
for the english name or LOCALE_SLOCALIZEDDISPLAYNAME
for the localized name).
Upvotes: 0
Reputation: 490008
GetUserDefaultLangID
may be what you're after. Then again, you may really be after GetUserPreferredUILanguages
.
Upvotes: 2
Reputation: 354356
What about GetUserDefaultUILanguage?
Word of caution: Never mistake the user's locale for their UI language. There are already enough broken applications out there.
Upvotes: 8