void UnregisterProfiles() { HRESULT hr = S_OK; ITfInputProcessorProfileMgr *pITfInputProcessorProfileMgr = nullptr; hr = CoCreateInstance(CLSID_TF_InputProcessorProfiles, NULL, CLSCTX_INPROC_SERVER, IID_ITfInputProcessorProfileMgr, (void**)&pITfInputProcessorProfileMgr); if (FAILED(hr)) { goto Exit; } hr = pITfInputProcessorProfileMgr->UnregisterProfile(Global::SampleIMECLSID, TEXTSERVICE_LANGID, Global::SampleIMEGuidProfile, 0); if (FAILED(hr)) { goto Exit; } Exit: if (pITfInputProcessorProfileMgr) { pITfInputProcessorProfileMgr->Release(); } return; }
BOOL RegisterProfiles() { HRESULT hr = S_FALSE; ITfInputProcessorProfileMgr *pITfInputProcessorProfileMgr = nullptr; hr = CoCreateInstance(CLSID_TF_InputProcessorProfiles, NULL, CLSCTX_INPROC_SERVER, IID_ITfInputProcessorProfileMgr, (void**)&pITfInputProcessorProfileMgr); if (FAILED(hr)) { return FALSE; } WCHAR achIconFile[MAX_PATH] = {'\0'}; DWORD cchA = 0; cchA = GetModuleFileName(Global::dllInstanceHandle, achIconFile, MAX_PATH); cchA = cchA >= MAX_PATH ? (MAX_PATH - 1) : cchA; achIconFile[cchA] = '\0'; size_t lenOfDesc = 0; hr = StringCchLength(TEXTSERVICE_DESC, STRSAFE_MAX_CCH, &lenOfDesc); if (hr != S_OK) { goto Exit; } hr = pITfInputProcessorProfileMgr->RegisterProfile(Global::SampleIMECLSID, TEXTSERVICE_LANGID, Global::SampleIMEGuidProfile, TEXTSERVICE_DESC, static_cast<ULONG>(lenOfDesc), achIconFile, cchA, (UINT)TEXTSERVICE_ICON_INDEX, NULL, 0, TRUE, 0); if (FAILED(hr)) { goto Exit; } Exit: if (pITfInputProcessorProfileMgr) { pITfInputProcessorProfileMgr->Release(); } return (hr == S_OK); }
void UnregisterProfiles() { HRESULT hr = S_OK; ITfInputProcessorProfileMgr *pITfInputProcessorProfileMgr = nullptr; hr = CoCreateInstance(CLSID_TF_InputProcessorProfiles, NULL, CLSCTX_INPROC_SERVER, IID_ITfInputProcessorProfileMgr, (void**)&pITfInputProcessorProfileMgr); if (FAILED(hr)) { goto Exit; } #ifndef NO_DAYI //Dayi profile hr = pITfInputProcessorProfileMgr->UnregisterProfile(Global::DIMECLSID, TEXTSERVICE_LANGID, Global::DIMEDayiGuidProfile, 0); if (FAILED(hr)) { goto Exit; } #endif //Array profile hr = pITfInputProcessorProfileMgr->UnregisterProfile(Global::DIMECLSID, TEXTSERVICE_LANGID, Global::DIMEArrayGuidProfile, 0); if (FAILED(hr)) { goto Exit; } //Phonetic profile hr = pITfInputProcessorProfileMgr->UnregisterProfile(Global::DIMECLSID, TEXTSERVICE_LANGID, Global::DIMEPhoneticGuidProfile, 0); if (FAILED(hr)) { goto Exit; } //Generic profile hr = pITfInputProcessorProfileMgr->UnregisterProfile(Global::DIMECLSID, TEXTSERVICE_LANGID, Global::DIMEGenericGuidProfile, 0); if (FAILED(hr)) { goto Exit; } Exit: if (pITfInputProcessorProfileMgr) { pITfInputProcessorProfileMgr->Release(); } return; }
BOOL RegisterProfiles() { HRESULT hr = S_FALSE; ITfInputProcessorProfileMgr *pITfInputProcessorProfileMgr = nullptr; hr = CoCreateInstance(CLSID_TF_InputProcessorProfiles, NULL, CLSCTX_INPROC_SERVER, IID_ITfInputProcessorProfileMgr, (void**)&pITfInputProcessorProfileMgr); if (FAILED(hr)) { return FALSE; } WCHAR achIconFile[MAX_PATH] = {'\0'}; DWORD cchA = 0; cchA = GetModuleFileName(Global::dllInstanceHandle, achIconFile, MAX_PATH); cchA = cchA >= MAX_PATH ? (MAX_PATH - 1) : cchA; achIconFile[cchA] = '\0'; size_t lenOfDesc = 0; WCHAR serviceDescripion[50]={'\0'};; //Dayi profile registration LoadString(Global::dllInstanceHandle, IDS_DAYI_DESCRIPTION, serviceDescripion, 50); hr = StringCchLength(serviceDescripion, STRSAFE_MAX_CCH, &lenOfDesc); if (hr != S_OK) { goto Exit; } hr = pITfInputProcessorProfileMgr->RegisterProfile(Global::DIMECLSID, TEXTSERVICE_LANGID, Global::DIMEDayiGuidProfile, serviceDescripion, static_cast<ULONG>(lenOfDesc), achIconFile, cchA, (UINT)TEXTSERVICE_DAYI_ICON_INDEX, NULL, 0, TRUE, 0); if (FAILED(hr)) { goto Exit; } //Array profile registration *serviceDescripion=L'\0'; LoadString(Global::dllInstanceHandle, IDS_ARRAY_DESCRIPTION, serviceDescripion, 50); hr = StringCchLength(serviceDescripion, STRSAFE_MAX_CCH, &lenOfDesc); if (hr != S_OK) { goto Exit; } hr = pITfInputProcessorProfileMgr->RegisterProfile(Global::DIMECLSID, TEXTSERVICE_LANGID, Global::DIMEArrayGuidProfile, serviceDescripion, static_cast<ULONG>(lenOfDesc), achIconFile, cchA, (UINT)TEXTSERVICE_ARRAY_ICON_INDEX, NULL, 0, TRUE, 0); if (FAILED(hr)) { goto Exit; } //Phonetic profile registration *serviceDescripion=L'\0'; LoadString(Global::dllInstanceHandle, IDS_PHONETIC_DESCRIPTION, serviceDescripion, 50); hr = StringCchLength(serviceDescripion, STRSAFE_MAX_CCH, &lenOfDesc); if (hr != S_OK) { goto Exit; } hr = pITfInputProcessorProfileMgr->RegisterProfile(Global::DIMECLSID, TEXTSERVICE_LANGID, Global::DIMEPhoneticGuidProfile, serviceDescripion, static_cast<ULONG>(lenOfDesc), achIconFile, cchA, (UINT)TEXTSERVICE_PHONETIC_ICON_INDEX, NULL, 0, TRUE, 0); if (FAILED(hr)) { goto Exit; } //Generic profile registration *serviceDescripion=L'\0'; LoadString(Global::dllInstanceHandle, IDS_GENERIC_DESCRIPTION, serviceDescripion, 50); hr = StringCchLength(serviceDescripion, STRSAFE_MAX_CCH, &lenOfDesc); if (hr != S_OK) { goto Exit; } hr = pITfInputProcessorProfileMgr->RegisterProfile(Global::DIMECLSID, TEXTSERVICE_LANGID, Global::DIMEGenericGuidProfile, serviceDescripion, static_cast<ULONG>(lenOfDesc), achIconFile, cchA, (UINT)TEXTSERVICE_GENERIC_ICON_INDEX, NULL, 0, TRUE, 0); if (FAILED(hr)) { goto Exit; } Exit: if (pITfInputProcessorProfileMgr) { pITfInputProcessorProfileMgr->Release(); } return (hr == S_OK); }