Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieving language name for keyboard layout from Win XP OS, using win API

Tags:

winapi

mfc

I am developing an app using VC6 on WIn XP. To retrieve default input language list from system GetKeyBoardLayoutList() and GetLocalInfo() APIs are used.

Follwoing is the code.

`UINT uLayouts; 
char szBuf[512];
HKL  *lpList = NULL;
uLayouts = GetKeyboardLayoutList(0, NULL);
lpList   = (HKL*)LocalAlloc(LPTR, (uLayouts * sizeof(HKL)));
uLayouts = GetKeyboardLayoutList(uLayouts, lpList);
for(UINT i = 0; i < uLayouts; i++)
{
    DWORD temp = (UINT)lpList[i] & 0xffffffff;
    GetLocaleInfo(MAKELCID(temp,SORT_DEFAULT), LOCALE_SLANGUAGE , szBuf, 512);
}`

In szBuf i am getting the input language name as "English (United States)" where as actaul name in OS is "English (United States) - US"

How can we get the exact name of input language present in the OS? We tried using different flags as well like,

LOCALE_SENGLANGUAGE //English

LOCALE_ILANGUAGE, LOCALE_SLANGUAGE, LOCALE_ICOUNTRY, LOCALE_SABBREVLANGNAME, LOCALE_SNATIVELANGNAME, LOCALE_SABBREVCTRYNAME, LOCALE_SNATIVECTRYNAME

however not able to fetch exact language name.

like image 202
Ajay Shinde Avatar asked Dec 19 '25 15:12

Ajay Shinde


1 Answers

use this:

 LOCALE_IMEASURE // 0 = metric, 1 = US
like image 143
Amit Kumar Avatar answered Dec 22 '25 16:12

Amit Kumar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!