From 67f117bcc2a36f6642580570d0c5361dc93adac5 Mon Sep 17 00:00:00 2001 From: QianmuZ Date: Tue, 25 Jul 2023 22:39:01 +0800 Subject: [PATCH] Update WeaselTSF.cpp --- WeaselTSF/WeaselTSF.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/WeaselTSF/WeaselTSF.cpp b/WeaselTSF/WeaselTSF.cpp index afbd8736a..dee4bfcf6 100644 --- a/WeaselTSF/WeaselTSF.cpp +++ b/WeaselTSF/WeaselTSF.cpp @@ -1,4 +1,4 @@ -#include "stdafx.h" +#include "stdafx.h" #include "WeaselTSF.h" #include "WeaselCommon.h" @@ -6,6 +6,10 @@ #include "LanguageBar.h" #include "Compartment.h" #include "ResponseParser.h" +#include +#include +#pragma comment(lib, "psapi.lib") +namespace fs = boost::filesystem; static void error_message(const WCHAR *msg) { @@ -34,6 +38,22 @@ WeaselTSF::WeaselTSF() _cand = new CCandidateList(this); DllAddRef(); + + auto pid = GetCurrentProcessId(); + + auto hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid); + + std::wstring name; + name.reserve(MAX_PATH); + + GetProcessImageFileName(hProcess, &name[0], name.capacity()); + name = &name[0]; + + CloseHandle(hProcess); + if (fs::path(name).filename().wstring() == L"WINWORD.EXE") + { + _WinWord = true; + } } WeaselTSF::~WeaselTSF()