[MSCTF][SDK] Implement TF_RegisterLangBarAddIn etc. (#6229)

- Add dll/win32/msctf/utils.cpp.
- Implement TF_RegisterLangBarAddIn
  and TF_UnregisterLangBarAddIn.
- Strengthen <cicero/cicreg.h>.
- Modify msctf.spec.
CORE-19361
This commit is contained in:
Katayama Hirofumi MZ 2023-12-26 10:31:53 +09:00 committed by GitHub
parent 434ac241df
commit a8a4703699
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 146 additions and 4 deletions

View file

@ -191,7 +191,7 @@ CicSystemModulePath::Init(
if (bSysWinDir)
{
// Usually C:\Windows or C:\ReactOS
cchPath = ::GetSystemWindowsDirectory(m_szPath, _countof(m_szPath));
cchPath = ::GetSystemWindowsDirectoryW(m_szPath, _countof(m_szPath));
}
else
{

View file

@ -15,7 +15,7 @@ public:
HKEY m_hKey;
CicRegKey() : m_hKey(NULL) { }
~CicRegKey() { Close(); }
virtual ~CicRegKey() { Close(); }
operator HKEY() { return m_hKey; }
@ -43,7 +43,7 @@ public:
LSTATUS SetDword(LPCWSTR pszValueName, DWORD dwValue)
{
return ::RegSetValueExW(m_hKey, pszValueName, 0, REG_DWORD, &dwValue, sizeof(dwValue));
return ::RegSetValueExW(m_hKey, pszValueName, 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(dwValue));
}
LSTATUS QuerySz(LPCWSTR pszValueName, LPWSTR pszValue, DWORD cchValueMax);
@ -53,6 +53,13 @@ public:
DWORD cbValue = (lstrlenW(pszValue) + 1) * sizeof(WCHAR);
return ::RegSetValueExW(m_hKey, pszValueName, 0, REG_SZ, (LPBYTE)pszValue, cbValue);
}
LSTATUS DeleteSubKey(LPCWSTR lpSubKey)
{
return ::RegDeleteKeyW(m_hKey, lpSubKey);
}
LSTATUS RecurseDeleteKey(LPCWSTR lpSubKey);
};
/******************************************************************************/
@ -124,3 +131,29 @@ CicRegKey::QuerySz(LPCWSTR pszValueName, LPWSTR pszValue, DWORD cchValueMax)
return error;
}
inline LSTATUS
CicRegKey::RecurseDeleteKey(LPCWSTR lpSubKey)
{
CicRegKey regKey;
LSTATUS error = regKey.Open(m_hKey, lpSubKey, KEY_READ | KEY_WRITE);
if (error != ERROR_SUCCESS)
return error;
WCHAR szName[MAX_PATH];
DWORD cchName;
do
{
cchName = _countof(szName);
error = ::RegEnumKeyExW(regKey, 0, szName, &cchName, NULL, NULL, NULL, NULL);
if (error != ERROR_SUCCESS)
break;
szName[_countof(szName) - 1] = UNICODE_NULL;
error = regKey.RecurseDeleteKey(szName);
} while (error == ERROR_SUCCESS);
regKey.Close();
return DeleteSubKey(lpSubKey);
}