From: Bill McCarthy on
Hi Jan,

"Jan Opitz" <next1(a)gmx.spam.de> wrote in message
news:%23LFLo1LVJHA.2084(a)TK2MSFTNGP06.phx.gbl...
> Hi Bill,
>
>> Const locale_JP = & H411
>> If (hKB(i) And locale_JP) = locale_JP Then ' is Japanese locale
>
> thank you very much for this.
>

You're welcome, although best to change that mask to &H7FFF&. See the code
below.


> However, using the hKB(i) value for the JP keyboard does not activate the
> JP IME (with Vista - it does with XP). Any more ideas?
>
>>> lngResult = LoadKeyboardLayout("E0010411", KLF_ACTIVATE)
>>
>> Not sure on this part. What's the "E0010411" ? Doesn't that value depend
>> on the hKB(i) value ?
>>
>

This is just a quick test that appears to be working here with Vista x64.

Option Explicit


Public Declare Function ImmIsIME Lib "imm32.dll" (ByVal hkl As Long) As Long
Public Declare Function GetKeyboardLayoutList Lib "user32" (ByVal nBuff As
Long, lpList As Long) As Long
Public Declare Function LoadKeyboardLayout Lib "user32" Alias
"LoadKeyboardLayoutA" (ByVal pwszKLID As String, ByVal flags As Long) As
Long
Public Const KLF_ACTIVATE = &H1


Public Sub ListIMEs()
Dim hKB() As Long
Dim rtn As Long, i As Long
Dim hKbCount As Long


rtn = GetKeyboardLayoutList(0, ByVal 0&)

If rtn <= 0 Then Exit Sub 'TODO throw an error if needed.

ReDim hKB(0 To rtn - 1)
hKbCount = GetKeyboardLayoutList(rtn, hKB(0))

For i = 0 To hKbCount - 1

If ImmIsIME(hKB(i)) <> 0 Then

If (hKB(i) And &H7FFF&) = &H411 Then

'it is japanese

Debug.Print "japanese found"

rtn = LoadKeyboardLayout(Hex(hKB(i)), KLF_ACTIVATE)

Debug.Print Hex(rtn)

End If
End If
Next




End Sub

Public Sub Main()
ListIMEs
End Sub