replace atlbas.h with wrl/client.h
Some checks are pending
Keyman Build Summary / Summarize build status checks (push) Waiting to run

This commit is contained in:
EberhardSchweizer07@gmail.com 2026-08-04 06:57:01 +02:00
parent 5ee388b1d7
commit 3abae6fb9c

View file

@ -16,7 +16,8 @@
#include <initguid.h> #include <initguid.h>
#include <comdef.h> #include <comdef.h>
#include <msctf.h> #include <msctf.h>
#include <atlbase.h> #include <wrl/client.h>
// #include <atlbase.h>
#include<sstream> #include<sstream>
#include<iomanip> #include<iomanip>
#include "kmtip_guids.h" #include "kmtip_guids.h"
@ -167,43 +168,51 @@ InstallLayoutOrTip(const wchar_t* FLayoutInstallString, DWORD Flags) {
return result ? true : false; return result ? true : false;
} }
// Unregister the TIP // Unregister the TIP
void UnregisterTIPAndItsProfiles(const CLSID& AClsid) { using Microsoft::WRL::ComPtr;
HRESULT hr;
CComPtr<ITfInputProcessorProfiles> pInputProcessorProfiles;
CComPtr<ITfInputProcessorProfileMgr> pInputProcessorProfileMgr;
CComPtr<IEnumTfInputProcessorProfiles> ippEnum;
ULONG pcFetch;
TF_INPUTPROCESSORPROFILE profile;
std::wstring FLayoutInstallString;
// Create an instance of ITF Input Processor Profiles void UnregisterTIPAndItsProfiles(const CLSID& AClsid)
hr = CoCreateInstance( {
CLSID_TF_InputProcessorProfiles, NULL, CLSCTX_INPROC_SERVER, IID_ITfInputProcessorProfiles, HRESULT hr;
(void**)&pInputProcessorProfiles); ComPtr<ITfInputProcessorProfiles> pInputProcessorProfiles;
if (FAILED(hr)) ComPtr<ITfInputProcessorProfileMgr> pInputProcessorProfileMgr;
throw _com_error(hr); ComPtr<IEnumTfInputProcessorProfiles> ippEnum;
// Query for ITfInputProcessorProfileMgr interface ULONG pcFetch;
hr = pInputProcessorProfiles->QueryInterface(IID_ITfInputProcessorProfileMgr, (void**)&pInputProcessorProfileMgr); TF_INPUTPROCESSORPROFILE profile;
if (FAILED(hr)) std::wstring FLayoutInstallString;
throw _com_error(hr);
// Enumerate the profiles hr = CoCreateInstance(
hr = pInputProcessorProfileMgr->EnumProfiles(0, &ippEnum); CLSID_TF_InputProcessorProfiles,
if (FAILED(hr)) nullptr,
throw _com_error(hr); CLSCTX_INPROC_SERVER,
IID_PPV_ARGS(pInputProcessorProfiles.GetAddressOf()));
if (FAILED(hr))
throw _com_error(hr);
// Unregister the input profiles installed through Keyman hr = pInputProcessorProfiles->QueryInterface(
while (ippEnum->Next(1, &profile, &pcFetch) == S_OK) { IID_PPV_ARGS(pInputProcessorProfileMgr.GetAddressOf()));
if (profile.dwProfileType == TF_PROFILETYPE_INPUTPROCESSOR && IsEqualGUID(profile.clsid, AClsid)) { if (FAILED(hr))
FLayoutInstallString = GetLayoutInstallString(profile.langid, profile.guidProfile); throw _com_error(hr);
InstallLayoutOrTip(FLayoutInstallString.c_str(), ILOT_UNINSTALL);
pInputProcessorProfileMgr->UnregisterProfile(AClsid, profile.langid, profile.guidProfile, 0); hr = pInputProcessorProfileMgr->EnumProfiles(
0,
ippEnum.GetAddressOf());
if (FAILED(hr))
throw _com_error(hr);
while (ippEnum->Next(1, &profile, &pcFetch) == S_OK)
{
if (profile.dwProfileType == TF_PROFILETYPE_INPUTPROCESSOR &&
IsEqualGUID(profile.clsid, AClsid))
{
FLayoutInstallString = GetLayoutInstallString(profile.langid, profile.guidProfile);
InstallLayoutOrTip(FLayoutInstallString.c_str(), ILOT_UNINSTALL);
pInputProcessorProfileMgr->UnregisterProfile(
AClsid, profile.langid, profile.guidProfile, 0);
}
} }
}
// Unregister the entire input processor pInputProcessorProfiles->Unregister(AClsid);
pInputProcessorProfiles->Unregister(AClsid);
} }
extern "C" __declspec(dllexport) UINT WINAPI PreUninstall( MSIHANDLE hInstall ) { extern "C" __declspec(dllexport) UINT WINAPI PreUninstall( MSIHANDLE hInstall ) {