Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions wind_tsf/src/Register.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#pragma comment(lib, "shlwapi.lib")

// --- GUID 定义区 ---
// DEFINE_GUID 在未定义 INITGUID 时只展开为声明,实际取值由链接期解析(uuid.lib
// 提供 SDK 真值),手写数值并不进链接产物。下方两个类别的手抄数值历史上与 SDK
// 真值不符,现对照 msctf.h 改为真值,属防御性修正:避免将来某个 TU 引入
// initguid.h 后错值突然生效。修改此处数值必须对照 msctf.h 逐字核对,勿凭记忆手写。

// Windows 8+ 沉浸式支持
DEFINE_GUID(GUID_TFCAT_TIPCAP_IMMERSIVESUPPORT,
Expand All @@ -18,13 +22,14 @@ DEFINE_GUID(GUID_TFCAT_TIPCAP_SYSTRAYSUPPORT,
0x25504FB4, 0x7BAB, 0x4BC1, 0x9C, 0x69, 0xCF, 0x81, 0x89, 0x0F, 0x0E, 0xF5);

// UI 元素支持 (候选窗口等现代 UI 渲染必备)
// {49D2F9CF-1F5E-11D7-A6D3-00065B84435C}
DEFINE_GUID(GUID_TFCAT_TIPCAP_UIELEMENTENABLED,
0x6D60FCCF, 0x58D7, 0x4B67, 0xB1, 0x3E, 0x96, 0xBE, 0x70, 0x6C, 0x3B, 0x6A);
0x49D2F9CF, 0x1F5E, 0x11D7, 0xA6, 0xD3, 0x00, 0x06, 0x5B, 0x84, 0x43, 0x5C);

// 安全模式支持 (开始菜单搜索框/锁屏等高权限宿主可能会筛选此能力)
// {3527B835-7383-4978-83C8-FD20C6F5A0E0}
// {49D2F9CE-1F5E-11D7-A6D3-00065B84435C}(与 UIELEMENTENABLED 为相邻的同族 GUID 对)
DEFINE_GUID(GUID_TFCAT_TIPCAP_SECUREMODE,
0x3527B835, 0x7383, 0x4978, 0x83, 0xC8, 0xFD, 0x20, 0xC6, 0xF5, 0xA0, 0xE0);
0x49D2F9CE, 0x1F5E, 0x11D7, 0xA6, 0xD3, 0x00, 0x06, 0x5B, 0x84, 0x43, 0x5C);

// --- 1. COM 服务器注册与卸载 ---
static HRESULT RegisterCOMServer()
Expand Down Expand Up @@ -62,9 +67,11 @@ static HRESULT RegisterCOMServer()
RegSetValueExW(hKey, nullptr, 0, REG_SZ, (BYTE*)szModule,
(lstrlenW(szModule) + 1) * sizeof(WCHAR));

// 【关键修复】:将 ThreadingModel 修改为 Both 以增强 Win11 现代应用兼容性
RegSetValueExW(hKey, L"ThreadingModel", 0, REG_SZ, (BYTE*)L"Both",
(lstrlenW(L"Both") + 1) * sizeof(WCHAR));
// TSF 标准线程模型:Apartment(weasel / SampleIME 同为 Apartment)。
// 历史上的 Both 系 Go 时代为「Win11 现代应用兼容」引入的 workaround 带入,
// 原始症状已失传;此处对齐 TSF 标准做法改回 Apartment。
RegSetValueExW(hKey, L"ThreadingModel", 0, REG_SZ, (BYTE*)L"Apartment",
(lstrlenW(L"Apartment") + 1) * sizeof(WCHAR));
RegCloseKey(hKey);
hr = S_OK;
}
Expand Down
Loading