Private Declare Function ImmEscape Lib "imm32.dll" Alias "ImmEscapeA" (ByVal hkl As Long, ByVal himc As Long, ByVal un As Long, lpv As Any) As Long Private Declare Function ImmGetConversionList Lib "imm32.dll" Alias "ImmGetConversionListA" (ByVal hkl As Long, ByVal himc As Long, ByVal lpsz As String, lpCandidateList As Any, ByVal dwBufLen As Long, ByVal uFlag As Long) As Long Private Declare Function GetKeyboardLayout Lib "user32" (ByVal dwLayout As Long) As Long Private Declare Function ImmIsIME Lib "imm32.dll" (ByVal hkl As Long) As Long Private Declare Function ImmSimulateHotKey Lib "imm32.dll" (ByVal hwnd As Long, ByVal dw As Long) As Long Private Const GCL_REVERSECONVERSION = &H2 Private Const IME_THOTKEY_IME_NONIME_TOGGLE = &H70 Private Const IME_ESC_MAX_KEY = &H1005 Private Type CANDIDATELIST dwSize As Long dwStyle As Long dwCount As Long dwSelection As Long dwPageStart As Long dwPageSize As Long dwOffset(1) As Long End Type Private Type POINTAPI x As Long y As Long End Type Private Type Msg hwnd As Long message As Long wParam As Long lParam As Long time As Long pt As POINTAPI End Type 'hkb: keyboard Handle, cChinaWord: Chinese Word , nth: the nth WordKey 'Start from 1 Public Function ImeQueryComp(ByVal hkb As Long, ByVal bChinaWord As String, Optional nth As Variant) As String Dim iMaxkey As Long, dwGCL As Long Dim tCandidate As CANDIDATELIST Dim iStart As Long, i As Long, j As Long, icount As Integer Dim dwBuff() As Byte Dim result() As Byte If IsMissing(nth) Then nth = 1 End If ImeQueryComp = "" iMaxkey = ImmEscape(hkb, 0, IME_ESC_MAX_KEY, vbNullString) If iMaxkey <= 0 Then Exit Function ' Check out whether support "Reverse Conversion" ' And Also the MaxKey dwGCL = ImmGetConversionList(hkb, 0, bChinaWord, _ tCandidate, 0, GCL_REVERSECONVERSION) If dwGCL <= 0 Then Exit Function '¸Ó¿é¤Jªk¤£¤ä´© Reverse Conversion ¥\¯à 'Getting WordKey value, dwGCL must be last call on ImmGetConversionList 'Resetting buffer ReDim dwBuff(dwGCL) dwGCL = ImmGetConversionList(hkb, 0, bChinaWord, dwBuff(0), _ dwGCL, GCL_REVERSECONVERSION) icount = dwBuff(8) ' getting how many Wordkey If dwGCL > 0 Then If nth > icount Then ' Wonder that NO Nth candidate Exit Function End If iStart = dwBuff(24 + (nth - 1) * 4) j = 0 ReDim result(iMaxkey * 2) For i = iStart To iStart + iMaxkey * 2 result(j) = dwBuff(i) j = j + 1 Next i ImeQueryComp = StrConv(result, vbUnicode) End If End Function 'Getting Current ctrl-space IME keyboard handle Public Function toChinese() As Long Dim hkb As Long Dim msgPeekResult As Msg Dim hwnd5 As Long hwnd5 = Screen.ActiveForm.hwnd DoEvents hkb = GetKeyboardLayout(0) If ImmIsIME(hkb) = 0 Then ImmSimulateHotKey hwnd5, IME_THOTKEY_IME_NONIME_TOGGLE DoEvents toChinese = GetKeyboardLayout(0) Else toChinese = hkb End If End Function -------------------------------------------------------------------------------- ' Usage & test ground: Dim hkb5 As Long Dim str5 As String 'Testing on Chinese word: "ªº" on Current IME hkb5 = toChinese() str5 = ImeQueryComp(hkb5, "ªº", 1) ' 1st WordKey Debug.Print str5 str5 = ImeQueryComp(hkb5, "ªº", 2) ' 2nd WordKey Debug.Print str5 str5 = ImeQueryComp(hkb5, "ªº", 3) ' 3rd WordKey Debug.Print str5*==================================================================