Is it possible to enumerate all the currently available keyboard layouts. By available I mean the user can switch to them by pressing Alt+Shift (or whatever his chosen shortcut is), i.e. they are in the Language Bar's menu.
Alternatively, checking if a specific layout is available in the Language Bar would also be useful.
Edit:
Many thanks to @oleg, I finally made a function that works:
bool IsActiveKeyboardLayout(DWORD dwPrimaryLangID)
{
TCHAR buf[KL_NAMELENGTH];
GetKeyboardLayoutName(buf);
DWORD dwActiveLangID = 0;
_stscanf(buf, _T("%X"), &dwActiveLangID);
if (dwPrimaryLangID == PRIMARYLANGID(dwActiveLangID))
return true;
return false;
}
bool IsKeyboardLayoutPresent(DWORD dwPrimaryLangID)
{
if (IsActiveKeyboardLayout(dwPrimaryLangID))
return true;
DWORD dwThreadID = GetCurrentThreadId();
HKL hOld = GetKeyboardLayout(dwThreadID);
for (;;)
{
ActivateKeyboardLayout((HKL) HKL_NEXT, 0);
if (hOld == GetKeyboardLayout(dwThreadID))
return false;
if (IsActiveKeyboardLayout(dwPrimaryLangID))
{
ActivateKeyboardLayout(hOld, 0);
return true;
}
}
}