[MSCTF] Implement TF_RunInputCPL (#6231)

- Add FullPathExec, and RunCPLSetting
  helper functions.
- Implement TF_RunInputCPL function
  by using them.
- Modify msctf.spec.
CORE-19361
This commit is contained in:
Katayama Hirofumi MZ 2023-12-26 13:39:56 +09:00 committed by GitHub
parent bfa3e554d4
commit 69a925cae8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 76 additions and 1 deletions

View file

@ -32,7 +32,7 @@
@ stub TF_IsCtfmonRunning
@ stub TF_IsInMarshaling
@ stub TF_MlngInfoCount
@ stub TF_RunInputCPL
@ stdcall TF_RunInputCPL()
@ stdcall -stub TF_PostAllThreadMsg(long long)
@ stdcall TF_RegisterLangBarAddIn(ptr wstr long)
@ stdcall TF_UnregisterLangBarAddIn(ptr long)

View file

@ -29,6 +29,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(msctf);
DWORD g_dwOSInfo = 0; // See cicGetOSInfo
BOOL StringFromGUID2A(REFGUID rguid, LPSTR pszGUID, INT cchGUID)
{
pszGUID[0] = ANSI_NULL;
@ -42,10 +44,53 @@ BOOL StringFromGUID2A(REFGUID rguid, LPSTR pszGUID, INT cchGUID)
#ifdef UNICODE
#define StringFromGUID2T StringFromGUID2
#define debugstr_t debugstr_w
#else
#define StringFromGUID2T StringFromGUID2A
#define debugstr_t debugstr_a
#endif
BOOL FullPathExec(LPCTSTR pszExeFile, LPCTSTR pszCmdLine, UINT nCmdShow, BOOL bSysWinDir)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
CicSystemModulePath ModPath;
TCHAR szCommandLine[2 * MAX_PATH];
ModPath.Init(pszExeFile, bSysWinDir);
if (!ModPath.m_cchPath)
{
ERR("%s\n", debugstr_t(pszExeFile));
return FALSE;
}
StringCchCopy(szCommandLine, _countof(szCommandLine), pszCmdLine);
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
si.wShowWindow = nCmdShow;
si.dwFlags = STARTF_USESHOWWINDOW;
if (!CreateProcess(ModPath.m_szPath, szCommandLine, NULL, NULL, FALSE,
NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi))
{
ERR("%s, %s\n", debugstr_t(ModPath.m_szPath), debugstr_t(szCommandLine));
return FALSE;
}
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
return TRUE;
}
static inline BOOL
RunCPLSetting(LPCTSTR pszCmdLine)
{
if (!pszCmdLine)
return FALSE;
return FullPathExec(TEXT("rundll32.exe"), pszCmdLine, SW_SHOWMINNOACTIVE, FALSE);
}
/***********************************************************************
* TF_RegisterLangBarAddIn (MSCTF.@)
*
@ -118,3 +163,33 @@ TF_UnregisterLangBarAddIn(
return hr;
}
/***********************************************************************
* TF_RunInputCPL (MSCTF.@)
*
* @implemented
*/
EXTERN_C HRESULT WINAPI
TF_RunInputCPL(VOID)
{
CicSystemModulePath ModPath;
TCHAR szCmdLine[2 * MAX_PATH];
TRACE("()\n");
// NOTE: We don't support Win95/98/Me
if (g_dwOSInfo & CIC_OSINFO_XPPLUS)
ModPath.Init(TEXT("input.dll"), FALSE);
else
ModPath.Init(TEXT("input.cpl"), FALSE);
if (!ModPath.m_cchPath)
return E_FAIL;
StringCchPrintf(szCmdLine, _countof(szCmdLine),
TEXT("rundll32.exe shell32.dll,Control_RunDLL %s"), ModPath.m_szPath);
if (!RunCPLSetting(szCmdLine))
return E_FAIL;
return S_OK;
}