GetKeyboardLayoutList(n, &hkls[0]);\r
for (std::vector<HKL>::const_iterator p = hkls.begin(); p != hkls.end(); ++p) {\r
IMEInfo info;\r
- if (ImmGetDescription(*p, info.szDescription, WINDOW_TEXT_LENGTH) &&\r
- ImmGetIMEFileName(*p, info.szFileName, MAX_PATH))\r
+ if (ImmGetDescription(*p, info.description, WINDOW_TEXT_LENGTH) &&\r
+ ImmGetIMEFileName(*p, info.filename, MAX_PATH))\r
list.push_back(info);\r
}\r
}\r
void IMEList::GetTSF()\r
{\r
CoInitialize(NULL);\r
- HRESULT hr;\r
- ITfInputProcessorProfiles *pProfiles;\r
- hr = CoCreateInstance(CLSID_TF_InputProcessorProfiles, NULL, CLSCTX_INPROC_SERVER, IID_ITfInputProcessorProfiles, reinterpret_cast<LPVOID*>(&pProfiles));\r
- if (FAILED(hr)) {\r
+ ITfInputProcessorProfiles *ipp;\r
+ if (FAILED(CoCreateInstance(CLSID_TF_InputProcessorProfiles, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&ipp)))) {\r
CoUninitialize();\r
return;\r
}\r
- const LANGID langid = GetUserDefaultLangID();\r
- IEnumTfLanguageProfiles *pEnum;\r
- hr = pProfiles->EnumLanguageProfiles(langid, &pEnum);\r
- if (FAILED(hr))\r
+ ITfInputProcessorProfileMgr *mgr;\r
+ if (FAILED(ipp->QueryInterface(&mgr)))\r
goto fail;\r
- TF_LANGUAGEPROFILE prof;\r
- ULONG fetch;\r
- while (pEnum->Next(1, &prof, &fetch) == S_OK) {\r
- if (!prof.fActive)\r
- continue;\r
- BSTR bstr;\r
- hr = pProfiles->GetLanguageProfileDescription(prof.clsid, langid, prof.guidProfile, &bstr);\r
- if (FAILED(hr))\r
- continue;\r
- IMEInfo info;\r
+ TF_INPUTPROCESSORPROFILE prof;\r
+ if (FAILED(mgr->GetActiveProfile(GUID_TFCAT_TIP_KEYBOARD, &prof))) {\r
+ mgr->Release();\r
+ goto fail;\r
+ }\r
+ mgr->Release();\r
+ if (prof.dwProfileType != TF_PROFILETYPE_INPUTPROCESSOR) // current IME is not TIP\r
+ goto fail;\r
+ BSTR bstr;\r
+ if (FAILED(ipp->GetLanguageProfileDescription(prof.clsid, prof.langid, prof.guidProfile, &bstr)))\r
+ goto fail;\r
+ IMEInfo info;\r
#ifdef _MBCS\r
- WideCharToMultiByte(CP_ACP, 0, bstr, -1, info.szDescription, MAX_PATH, NULL, NULL);\r
+ WideCharToMultiByte(CP_ACP, 0, bstr, -1, info.description, WINDOW_TEXT_LENGTH, NULL, NULL);\r
#else\r
- wcscpy_s(info.szDescription, WINDOW_TEXT_LENGTH, bstr);\r
+ wcscpy_s(info.description, WINDOW_TEXT_LENGTH, bstr);\r
#endif\r
- bool exist = false;\r
- for (IMEListIterator p = list.begin(); p != list.end(); ++p)\r
- if (!_tcscmp(info.szDescription, p->szDescription)) { // already get via IMM\r
- exist = true;\r
- break;\r
- }\r
- if (!exist) {\r
- _tcscpy_s(info.szFileName, _T("IME"));\r
- list.push_back(info);\r
- break;\r
- }\r
- }\r
- pEnum->Release();\r
+ _tcscpy_s(info.filename, _T("IME"));\r
+ list.push_back(info);\r
fail:\r
- pProfiles->Release();\r
+ ipp->Release();\r
CoUninitialize();\r
}\r