[CTFMON][MSCTFIME][MSCTF][MSUTB][SDK] Cicero is ANSI, not Unicode (#6230)

Cicero interface is not Unicode (W)
but ANSI (A).
- ctfmon.exe is ANSI, not Unicode.
- msutb.dll is ANSI, not Unicode.
- Apply generic text mapping to the
  cicero headers.
- Include <tchar.h> to use generic
  text mapping.
CORE-19361, CORE-19362, CORE-19363
This commit is contained in:
Katayama Hirofumi MZ 2023-12-26 12:07:01 +09:00 committed by GitHub
parent a8a4703699
commit bfa3e554d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 197 additions and 156 deletions

View file

@ -18,15 +18,15 @@ BOOL CLoaderWnd::Init()
return TRUE; // Already registered return TRUE; // Already registered
// Register a window class // Register a window class
WNDCLASSEXW wc; WNDCLASSEX wc;
ZeroMemory(&wc, sizeof(wc)); ZeroMemory(&wc, sizeof(wc));
wc.cbSize = sizeof(wc); wc.cbSize = sizeof(wc);
wc.style = CS_HREDRAW | CS_VREDRAW; wc.style = CS_HREDRAW | CS_VREDRAW;
wc.hInstance = g_hInst; wc.hInstance = g_hInst;
wc.hCursor = LoadCursorW(NULL, (LPCWSTR)IDC_ARROW); wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.lpfnWndProc = WindowProc; wc.lpfnWndProc = WindowProc;
wc.lpszClassName = L"CiCTipBarClass"; wc.lpszClassName = TEXT("CiCTipBarClass");
if (!::RegisterClassExW(&wc)) if (!::RegisterClassEx(&wc))
return FALSE; return FALSE;
s_bWndClassRegistered = TRUE; // Remember s_bWndClassRegistered = TRUE; // Remember
@ -35,7 +35,7 @@ BOOL CLoaderWnd::Init()
HWND CLoaderWnd::CreateWnd() HWND CLoaderWnd::CreateWnd()
{ {
m_hWnd = ::CreateWindowExW(0, L"CiCTipBarClass", NULL, WS_DISABLED, m_hWnd = ::CreateWindowEx(0, TEXT("CiCTipBarClass"), NULL, WS_DISABLED,
0, 0, 0, 0, NULL, NULL, g_hInst, NULL); 0, 0, 0, 0, NULL, NULL, g_hInst, NULL);
return m_hWnd; return m_hWnd;
} }
@ -93,7 +93,7 @@ CLoaderWnd::WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
break; break;
default: default:
return DefWindowProcW(hwnd, uMsg, wParam, lParam); return DefWindowProc(hwnd, uMsg, wParam, lParam);
} }
return 0; return 0;

View file

@ -6,7 +6,7 @@ list(APPEND SOURCE
add_rc_deps(ctfmon.rc ${CMAKE_CURRENT_SOURCE_DIR}/res/ctfmon.ico) add_rc_deps(ctfmon.rc ${CMAKE_CURRENT_SOURCE_DIR}/res/ctfmon.ico)
add_executable(ctfmon ${SOURCE} ctfmon.rc) add_executable(ctfmon ${SOURCE} ctfmon.rc)
set_module_type(ctfmon win32gui UNICODE) set_module_type(ctfmon win32gui)
add_dependencies(ctfmon msctf msutb) add_dependencies(ctfmon msctf msutb)
target_link_libraries(ctfmon uuid) target_link_libraries(ctfmon uuid)
add_importlibs(ctfmon msctf msutb advapi32 shell32 user32 msvcrt kernel32) add_importlibs(ctfmon msctf msutb advapi32 shell32 user32 msvcrt kernel32)

View file

@ -14,18 +14,18 @@ HANDLE CRegWatcher::s_ahWatchEvents[WATCHENTRY_MAX] = { NULL };
// The registry entries to watch // The registry entries to watch
WATCHENTRY CRegWatcher::s_WatchEntries[WATCHENTRY_MAX] = WATCHENTRY CRegWatcher::s_WatchEntries[WATCHENTRY_MAX] =
{ {
{ HKEY_CURRENT_USER, L"Keyboard Layout\\Toggle" }, // WI_TOGGLE { HKEY_CURRENT_USER, TEXT("Keyboard Layout\\Toggle") }, // WI_TOGGLE
{ HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\CTF\\TIP" }, // WI_MACHINE_TIF { HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\CTF\\TIP") }, // WI_MACHINE_TIF
{ HKEY_CURRENT_USER, L"Keyboard Layout\\Preload" }, // WI_PRELOAD { HKEY_CURRENT_USER, TEXT("Keyboard Layout\\Preload") }, // WI_PRELOAD
{ HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run" }, // WI_RUN { HKEY_CURRENT_USER, TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run") }, // WI_RUN
{ HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\CTF\\TIP" }, // WI_USER_TIF { HKEY_CURRENT_USER, TEXT("SOFTWARE\\Microsoft\\CTF\\TIP") }, // WI_USER_TIF
{ HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Speech" }, // WI_USER_SPEECH { HKEY_CURRENT_USER, TEXT("SOFTWARE\\Microsoft\\Speech") }, // WI_USER_SPEECH
{ HKEY_CURRENT_USER, L"Control Panel\\Appearance" }, // WI_APPEARANCE { HKEY_CURRENT_USER, TEXT("Control Panel\\Appearance") }, // WI_APPEARANCE
{ HKEY_CURRENT_USER, L"Control Panel\\Colors" }, // WI_COLORS { HKEY_CURRENT_USER, TEXT("Control Panel\\Colors") }, // WI_COLORS
{ HKEY_CURRENT_USER, L"Control Panel\\Desktop\\WindowMetrics" }, // WI_WINDOW_METRICS { HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop\\WindowMetrics") }, // WI_WINDOW_METRICS
{ HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Speech" }, // WI_MACHINE_SPEECH { HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Speech") }, // WI_MACHINE_SPEECH
{ HKEY_CURRENT_USER, L"Keyboard Layout" }, // WI_KEYBOARD_LAYOUT { HKEY_CURRENT_USER, TEXT("Keyboard Layout") }, // WI_KEYBOARD_LAYOUT
{ HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\CTF\\Assemblies" }, // WI_ASSEMBLIES { HKEY_CURRENT_USER, TEXT("SOFTWARE\\Microsoft\\CTF\\Assemblies") }, // WI_ASSEMBLIES
}; };
// The timer IDs: For delaying ignitions // The timer IDs: For delaying ignitions
@ -48,7 +48,7 @@ CRegWatcher::Init()
// Create some nameless events and initialize them // Create some nameless events and initialize them
for (SIZE_T iEvent = 0; iEvent < _countof(s_ahWatchEvents); ++iEvent) for (SIZE_T iEvent = 0; iEvent < _countof(s_ahWatchEvents); ++iEvent)
{ {
s_ahWatchEvents[iEvent] = ::CreateEventW(NULL, TRUE, FALSE, NULL); s_ahWatchEvents[iEvent] = ::CreateEvent(NULL, TRUE, FALSE, NULL);
InitEvent(iEvent, FALSE); InitEvent(iEvent, FALSE);
} }
@ -102,10 +102,10 @@ CRegWatcher::InitEvent(
// Open or create a registry key to watch registry key // Open or create a registry key to watch registry key
LSTATUS error; LSTATUS error;
error = ::RegOpenKeyExW(entry.hRootKey, entry.pszSubKey, 0, KEY_READ, &entry.hKey); error = ::RegOpenKeyEx(entry.hRootKey, entry.pszSubKey, 0, KEY_READ, &entry.hKey);
if (error != ERROR_SUCCESS) if (error != ERROR_SUCCESS)
{ {
error = ::RegCreateKeyExW(entry.hRootKey, entry.pszSubKey, 0, NULL, 0, error = ::RegCreateKeyEx(entry.hRootKey, entry.pszSubKey, 0, NULL, 0,
KEY_ALL_ACCESS, NULL, &entry.hKey, NULL); KEY_ALL_ACCESS, NULL, &entry.hKey, NULL);
if (error != ERROR_SUCCESS) if (error != ERROR_SUCCESS)
return FALSE; return FALSE;
@ -128,17 +128,18 @@ CRegWatcher::UpdateSpTip()
// Clear "ProfileInitialized" value // Clear "ProfileInitialized" value
HKEY hKey; HKEY hKey;
LSTATUS error = ::RegOpenKeyExW(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\CTF\\Sapilayr", LSTATUS error = ::RegOpenKeyEx(HKEY_CURRENT_USER,
TEXT("SOFTWARE\\Microsoft\\CTF\\Sapilayr"),
0, KEY_WRITE, &hKey); 0, KEY_WRITE, &hKey);
if (error == ERROR_SUCCESS) if (error == ERROR_SUCCESS)
{ {
DWORD dwValue = 0, cbValue = sizeof(dwValue); DWORD dwValue = 0, cbValue = sizeof(dwValue);
::RegSetValueExW(hKey, L"ProfileInitialized", NULL, REG_DWORD, (LPBYTE)&dwValue, cbValue); ::RegSetValueEx(hKey, TEXT("ProfileInitialized"), NULL, REG_DWORD, (LPBYTE)&dwValue, cbValue);
::RegCloseKey(hKey); ::RegCloseKey(hKey);
} }
// Get %WINDIR%/IME/sptip.dll!TF_CreateLangProfileUtil function // Get %WINDIR%/IME/sptip.dll!TF_CreateLangProfileUtil function
HINSTANCE hSPTIP = cicLoadSystemLibrary(L"IME\\sptip.dll", TRUE); HINSTANCE hSPTIP = cicLoadSystemLibrary(TEXT("IME\\sptip.dll"), TRUE);
FN_TF_CreateLangProfileUtil fnTF_CreateLangProfileUtil = FN_TF_CreateLangProfileUtil fnTF_CreateLangProfileUtil =
(FN_TF_CreateLangProfileUtil)::GetProcAddress(hSPTIP, "TF_CreateLangProfileUtil"); (FN_TF_CreateLangProfileUtil)::GetProcAddress(hSPTIP, "TF_CreateLangProfileUtil");
if (fnTF_CreateLangProfileUtil) if (fnTF_CreateLangProfileUtil)
@ -168,17 +169,17 @@ CRegWatcher::KillInternat()
WATCHENTRY& entry = s_WatchEntries[WI_RUN]; WATCHENTRY& entry = s_WatchEntries[WI_RUN];
// Delete internat.exe from registry "Run" key // Delete internat.exe from registry "Run" key
LSTATUS error = ::RegOpenKeyExW(entry.hRootKey, entry.pszSubKey, 0, KEY_ALL_ACCESS, &hKey); LSTATUS error = ::RegOpenKeyEx(entry.hRootKey, entry.pszSubKey, 0, KEY_ALL_ACCESS, &hKey);
if (error == ERROR_SUCCESS) if (error == ERROR_SUCCESS)
{ {
::RegDeleteValueW(hKey, L"internat.exe"); ::RegDeleteValue(hKey, TEXT("internat.exe"));
::RegCloseKey(hKey); ::RegCloseKey(hKey);
} }
// Kill the "Indicator" window (that internat.exe creates) // Kill the "Indicator" window (that internat.exe creates)
HWND hwndInternat = ::FindWindowW(L"Indicator", NULL); HWND hwndInternat = ::FindWindow(TEXT("Indicator"), NULL);
if (hwndInternat) if (hwndInternat)
::PostMessageW(hwndInternat, WM_CLOSE, 0, 0); ::PostMessage(hwndInternat, WM_CLOSE, 0, 0);
} }
// Post message 0x8002 to every "SapiTipWorkerClass" window. // Post message 0x8002 to every "SapiTipWorkerClass" window.
@ -188,14 +189,14 @@ CRegWatcher::EnumWndProc(
_In_ HWND hWnd, _In_ HWND hWnd,
_In_ LPARAM lParam) _In_ LPARAM lParam)
{ {
WCHAR ClassName[MAX_PATH]; TCHAR ClassName[MAX_PATH];
UNREFERENCED_PARAMETER(lParam); UNREFERENCED_PARAMETER(lParam);
if (::GetClassNameW(hWnd, ClassName, _countof(ClassName)) && if (::GetClassName(hWnd, ClassName, _countof(ClassName)) &&
_wcsicmp(ClassName, L"SapiTipWorkerClass") == 0) _tcsicmp(ClassName, TEXT("SapiTipWorkerClass")) == 0)
{ {
PostMessageW(hWnd, 0x8002, 0, 0); // FIXME: Magic number PostMessage(hWnd, 0x8002, 0, 0); // FIXME: Magic number
} }
return TRUE; return TRUE;

View file

@ -10,7 +10,7 @@
struct WATCHENTRY struct WATCHENTRY
{ {
HKEY hRootKey; HKEY hRootKey;
LPCWSTR pszSubKey; LPCTSTR pszSubKey;
HKEY hKey; HKEY hKey;
}; };

View file

@ -13,6 +13,9 @@
typedef BOOL (WINAPI *FN_SetProcessShutdownParameters)(DWORD, DWORD); typedef BOOL (WINAPI *FN_SetProcessShutdownParameters)(DWORD, DWORD);
FN_SetProcessShutdownParameters g_fnSetProcessShutdownParameters = NULL; FN_SetProcessShutdownParameters g_fnSetProcessShutdownParameters = NULL;
// kernel32!GetSystemWow64DirectoryA
typedef UINT (WINAPI *FN_GetSystemWow64DirectoryA)(LPSTR, UINT);
FN_GetSystemWow64DirectoryA g_fnGetSystemWow64DirectoryA = NULL;
// kernel32!GetSystemWow64DirectoryW // kernel32!GetSystemWow64DirectoryW
typedef UINT (WINAPI *FN_GetSystemWow64DirectoryW)(LPWSTR, UINT); typedef UINT (WINAPI *FN_GetSystemWow64DirectoryW)(LPWSTR, UINT);
FN_GetSystemWow64DirectoryW g_fnGetSystemWow64DirectoryW = NULL; FN_GetSystemWow64DirectoryW g_fnGetSystemWow64DirectoryW = NULL;
@ -30,29 +33,29 @@ CLoaderWnd* g_pLoaderWnd = NULL; // Tipbar loader window
static VOID static VOID
ParseCommandLine( ParseCommandLine(
_In_ LPCWSTR pszCmdLine) _In_ LPCTSTR pszCmdLine)
{ {
g_fNoRunKey = g_fJustRunKey = FALSE; g_fNoRunKey = g_fJustRunKey = FALSE;
for (LPCWSTR pch = pszCmdLine; *pch; ++pch) for (LPCTSTR pch = pszCmdLine; *pch; ++pch)
{ {
// Skip space // Skip space
while (*pch == L' ') while (*pch == TEXT(' '))
++pch; ++pch;
if (*pch == UNICODE_NULL) if (*pch == TEXT('\0'))
return; return;
if ((*pch == L'-') || (*pch == L'/')) if ((*pch == TEXT('-')) || (*pch == TEXT('/')))
{ {
++pch; ++pch;
switch (*pch) switch (*pch)
{ {
case L'N': case L'n': // Found "/N" option case TEXT('N'): case TEXT('n'): // Found "/N" option
g_fNoRunKey = TRUE; g_fNoRunKey = TRUE;
break; break;
case L'R': case L'r': // Found "/R" option case TEXT('R'): case TEXT('r'): // Found "/R" option
g_fJustRunKey = TRUE; g_fJustRunKey = TRUE;
break; break;
@ -74,18 +77,18 @@ WriteRegRun(VOID)
// Open "Run" key // Open "Run" key
HKEY hKey; HKEY hKey;
LSTATUS error = ::RegCreateKeyW(HKEY_CURRENT_USER, LSTATUS error = ::RegCreateKey(HKEY_CURRENT_USER,
L"Software\\Microsoft\\Windows\\CurrentVersion\\Run", TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Run"),
&hKey); &hKey);
if (error != ERROR_SUCCESS) if (error != ERROR_SUCCESS)
return; return;
// Write the module path // Write the module path
CicSystemModulePath ModPath; CicSystemModulePath ModPath;
if (ModPath.Init(L"ctfmon.exe", FALSE)) if (ModPath.Init(TEXT("ctfmon.exe"), FALSE))
{ {
DWORD cbData = (ModPath.m_cchPath + 1) * sizeof(WCHAR); DWORD cbData = (ModPath.m_cchPath + 1) * sizeof(TCHAR);
::RegSetValueExW(hKey, L"ctfmon.exe", 0, REG_SZ, (BYTE*)ModPath.m_szPath, cbData); ::RegSetValueEx(hKey, TEXT("ctfmon.exe"), 0, REG_SZ, (BYTE*)ModPath.m_szPath, cbData);
} }
::RegCloseKey(hKey); ::RegCloseKey(hKey);
@ -134,7 +137,7 @@ SetGlobalCompartmentDWORD(
static BOOL static BOOL
CheckX64System( CheckX64System(
_In_ LPWSTR lpCmdLine) _In_ LPTSTR lpCmdLine)
{ {
// Is the system x64? // Is the system x64?
SYSTEM_INFO SystemInfo; SYSTEM_INFO SystemInfo;
@ -146,23 +149,34 @@ CheckX64System(
} }
// Get GetSystemWow64DirectoryW function // Get GetSystemWow64DirectoryW function
g_hKernel32 = cicGetSystemModuleHandle(L"kernel32.dll", FALSE); g_hKernel32 = cicGetSystemModuleHandle(TEXT("kernel32.dll"), FALSE);
#ifdef UNICODE
g_fnGetSystemWow64DirectoryW = g_fnGetSystemWow64DirectoryW =
(FN_GetSystemWow64DirectoryW)::GetProcAddress(g_hKernel32, "GetSystemWow64DirectoryW"); (FN_GetSystemWow64DirectoryW)::GetProcAddress(g_hKernel32, "GetSystemWow64DirectoryW");
if (!g_fnGetSystemWow64DirectoryW) if (!g_fnGetSystemWow64DirectoryW)
return FALSE; return FALSE;
#else
g_fnGetSystemWow64DirectoryA =
(FN_GetSystemWow64DirectoryA)::GetProcAddress(g_hKernel32, "GetSystemWow64DirectoryA");
if (!g_fnGetSystemWow64DirectoryA)
return FALSE;
#endif
// Build WoW64 ctfmon.exe pathname // Build WoW64 ctfmon.exe pathname
WCHAR szPath[MAX_PATH]; TCHAR szPath[MAX_PATH];
#ifdef UNICODE
UINT cchPath = g_fnGetSystemWow64DirectoryW(szPath, _countof(szPath)); UINT cchPath = g_fnGetSystemWow64DirectoryW(szPath, _countof(szPath));
if (!cchPath && FAILED(StringCchCatW(szPath, _countof(szPath), L"\\ctfmon.exe"))) #else
UINT cchPath = g_fnGetSystemWow64DirectoryA(szPath, _countof(szPath));
#endif
if (!cchPath && FAILED(StringCchCat(szPath, _countof(szPath), TEXT("\\ctfmon.exe"))))
return FALSE; return FALSE;
// Create a WoW64 ctfmon.exe process // Create a WoW64 ctfmon.exe process
PROCESS_INFORMATION pi; PROCESS_INFORMATION pi;
STARTUPINFOW si = { sizeof(si) }; STARTUPINFO si = { sizeof(si) };
si.wShowWindow = SW_SHOWMINNOACTIVE; si.wShowWindow = SW_SHOWMINNOACTIVE;
if (!::CreateProcessW(szPath, lpCmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) if (!::CreateProcess(szPath, lpCmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
return FALSE; return FALSE;
::CloseHandle(pi.hThread); ::CloseHandle(pi.hThread);
@ -173,7 +187,7 @@ CheckX64System(
static BOOL static BOOL
InitApp( InitApp(
_In_ HINSTANCE hInstance, _In_ HINSTANCE hInstance,
_In_ LPWSTR lpCmdLine) _In_ LPTSTR lpCmdLine)
{ {
g_hInst = hInstance; // Save the instance handle g_hInst = hInstance; // Save the instance handle
@ -194,7 +208,7 @@ InitApp(
// Call SetProcessShutdownParameters if possible // Call SetProcessShutdownParameters if possible
if (g_dwOsInfo & CIC_OSINFO_NT) if (g_dwOsInfo & CIC_OSINFO_NT)
{ {
g_hKernel32 = cicGetSystemModuleHandle(L"kernel32.dll", FALSE); g_hKernel32 = cicGetSystemModuleHandle(TEXT("kernel32.dll"), FALSE);
g_fnSetProcessShutdownParameters = g_fnSetProcessShutdownParameters =
(FN_SetProcessShutdownParameters) (FN_SetProcessShutdownParameters)
::GetProcAddress(g_hKernel32, "SetProcessShutdownParameters"); ::GetProcAddress(g_hKernel32, "SetProcessShutdownParameters");
@ -257,16 +271,16 @@ DoMainLoop(VOID)
if (g_bOnWow64) // Is the current process on WoW64? if (g_bOnWow64) // Is the current process on WoW64?
{ {
// Just a simple message loop // Just a simple message loop
while (::GetMessageW(&msg, NULL, 0, 0)) while (::GetMessage(&msg, NULL, 0, 0))
{ {
::TranslateMessage(&msg); ::TranslateMessage(&msg);
::DispatchMessageW(&msg); ::DispatchMessage(&msg);
} }
return (INT)msg.wParam; return (INT)msg.wParam;
} }
// Open the existing event by the name // Open the existing event by the name
HANDLE hSwitchEvent = ::OpenEventW(SYNCHRONIZE, FALSE, L"WinSta0_DesktopSwitch"); HANDLE hSwitchEvent = ::OpenEvent(SYNCHRONIZE, FALSE, TEXT("WinSta0_DesktopSwitch"));
// The target events to watch // The target events to watch
HANDLE ahEvents[WATCHENTRY_MAX + 1]; HANDLE ahEvents[WATCHENTRY_MAX + 1];
@ -285,13 +299,13 @@ DoMainLoop(VOID)
if (dwWait == (WAIT_OBJECT_0 + _countof(ahEvents))) // Is input available? if (dwWait == (WAIT_OBJECT_0 + _countof(ahEvents))) // Is input available?
{ {
// Do the events // Do the events
while (::PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) while (::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{ {
if (msg.message == WM_QUIT) if (msg.message == WM_QUIT)
goto Quit; goto Quit;
::TranslateMessage(&msg); ::TranslateMessage(&msg);
::DispatchMessageW(&msg); ::DispatchMessage(&msg);
} }
} }
else if (dwWait == (WAIT_OBJECT_0 + WI_DESKTOP_SWITCH)) // Desktop switch? else if (dwWait == (WAIT_OBJECT_0 + WI_DESKTOP_SWITCH)) // Desktop switch?
@ -313,10 +327,10 @@ Quit:
// The main function for Unicode Win32 // The main function for Unicode Win32
EXTERN_C INT WINAPI EXTERN_C INT WINAPI
wWinMain( _tWinMain(
HINSTANCE hInstance, HINSTANCE hInstance,
HINSTANCE hPrevInst, HINSTANCE hPrevInst,
LPWSTR lpCmdLine, LPTSTR lpCmdLine,
INT nCmdShow) INT nCmdShow)
{ {
UNREFERENCED_PARAMETER(hPrevInst); UNREFERENCED_PARAMETER(hPrevInst);

View file

@ -12,6 +12,7 @@
#include <shellapi.h> #include <shellapi.h>
#include <shlwapi.h> #include <shlwapi.h>
#include <stdlib.h> #include <stdlib.h>
#include <tchar.h>
#include <strsafe.h> #include <strsafe.h>
#include <msctf.h> #include <msctf.h>
#include <ctfutb.h> #include <ctfutb.h>

View file

@ -56,16 +56,17 @@ BOOL IsMsImeMessage(UINT uMsg)
*/ */
BOOL RegisterMSIMEMessage(VOID) BOOL RegisterMSIMEMessage(VOID)
{ {
WM_MSIME_SERVICE = RegisterWindowMessageW(L"MSIMEService"); // Using ANSI (A) version here can reduce binary size.
WM_MSIME_UIREADY = RegisterWindowMessageW(L"MSIMEUIReady"); WM_MSIME_SERVICE = RegisterWindowMessageA("MSIMEService");
WM_MSIME_RECONVERTREQUEST = RegisterWindowMessageW(L"MSIMEReconvertRequest"); WM_MSIME_UIREADY = RegisterWindowMessageA("MSIMEUIReady");
WM_MSIME_RECONVERT = RegisterWindowMessageW(L"MSIMEReconvert"); WM_MSIME_RECONVERTREQUEST = RegisterWindowMessageA("MSIMEReconvertRequest");
WM_MSIME_DOCUMENTFEED = RegisterWindowMessageW(L"MSIMEDocumentFeed"); WM_MSIME_RECONVERT = RegisterWindowMessageA("MSIMEReconvert");
WM_MSIME_QUERYPOSITION = RegisterWindowMessageW(L"MSIMEQueryPosition"); WM_MSIME_DOCUMENTFEED = RegisterWindowMessageA("MSIMEDocumentFeed");
WM_MSIME_MODEBIAS = RegisterWindowMessageW(L"MSIMEModeBias"); WM_MSIME_QUERYPOSITION = RegisterWindowMessageA("MSIMEQueryPosition");
WM_MSIME_SHOWIMEPAD = RegisterWindowMessageW(L"MSIMEShowImePad"); WM_MSIME_MODEBIAS = RegisterWindowMessageA("MSIMEModeBias");
WM_MSIME_MOUSE = RegisterWindowMessageW(L"MSIMEMouseOperation"); WM_MSIME_SHOWIMEPAD = RegisterWindowMessageA("MSIMEShowImePad");
WM_MSIME_KEYMAP = RegisterWindowMessageW(L"MSIMEKeyMap"); WM_MSIME_MOUSE = RegisterWindowMessageA("MSIMEMouseOperation");
WM_MSIME_KEYMAP = RegisterWindowMessageA("MSIMEKeyMap");
return (WM_MSIME_SERVICE && return (WM_MSIME_SERVICE &&
WM_MSIME_UIREADY && WM_MSIME_UIREADY &&
WM_MSIME_RECONVERTREQUEST && WM_MSIME_RECONVERTREQUEST &&

View file

@ -17,6 +17,7 @@
#include <imm.h> #include <imm.h>
#include <ddk/immdev.h> #include <ddk/immdev.h>
#include <cguid.h> #include <cguid.h>
#include <tchar.h>
#include <msctf.h> #include <msctf.h>
#include <ctffunc.h> #include <ctffunc.h>
#include <shlwapi.h> #include <shlwapi.h>

View file

@ -17,6 +17,7 @@
#include <imm.h> #include <imm.h>
#include <ddk/immdev.h> #include <ddk/immdev.h>
#include <cguid.h> #include <cguid.h>
#include <tchar.h>
#include <msctf.h> #include <msctf.h>
#include <ctffunc.h> #include <ctffunc.h>
#include <shlwapi.h> #include <shlwapi.h>
@ -28,6 +29,23 @@
WINE_DEFAULT_DEBUG_CHANNEL(msctf); WINE_DEFAULT_DEBUG_CHANNEL(msctf);
BOOL StringFromGUID2A(REFGUID rguid, LPSTR pszGUID, INT cchGUID)
{
pszGUID[0] = ANSI_NULL;
WCHAR szWide[40];
szWide[0] = UNICODE_NULL;
BOOL ret = StringFromGUID2(rguid, szWide, _countof(szWide));
::WideCharToMultiByte(CP_ACP, 0, szWide, -1, pszGUID, cchGUID, NULL, NULL);
return ret;
}
#ifdef UNICODE
#define StringFromGUID2T StringFromGUID2
#else
#define StringFromGUID2T StringFromGUID2A
#endif
/*********************************************************************** /***********************************************************************
* TF_RegisterLangBarAddIn (MSCTF.@) * TF_RegisterLangBarAddIn (MSCTF.@)
* *
@ -47,19 +65,19 @@ TF_RegisterLangBarAddIn(
return E_INVALIDARG; return E_INVALIDARG;
} }
WCHAR szBuff[MAX_PATH], szGUID[40]; TCHAR szBuff[MAX_PATH], szGUID[40];
StringCchCopyW(szBuff, _countof(szBuff), L"SOFTWARE\\Microsoft\\CTF\\LangBarAddIn\\"); StringCchCopy(szBuff, _countof(szBuff), TEXT("SOFTWARE\\Microsoft\\CTF\\LangBarAddIn\\"));
StringFromGUID2(rguid, szGUID, _countof(szGUID)); StringFromGUID2T(rguid, szGUID, _countof(szGUID));
StringCchCatW(szBuff, _countof(szBuff), szGUID); StringCchCat(szBuff, _countof(szBuff), szGUID);
CicRegKey regKey; CicRegKey regKey;
HKEY hBaseKey = ((dwFlags & 1) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER); HKEY hBaseKey = ((dwFlags & 1) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER);
LSTATUS error = regKey.Create(hBaseKey, szBuff); LSTATUS error = regKey.Create(hBaseKey, szBuff);
if (error == ERROR_SUCCESS) if (error == ERROR_SUCCESS)
{ {
error = regKey.SetSz(L"FilePath", pszFilePath); error = regKey.SetSzW(L"FilePath", pszFilePath);
if (error == ERROR_SUCCESS) if (error == ERROR_SUCCESS)
error = regKey.SetDword(L"Enable", !!(dwFlags & 4)); error = regKey.SetDword(TEXT("Enable"), !!(dwFlags & 4));
} }
return ((error == ERROR_SUCCESS) ? S_OK : E_FAIL); return ((error == ERROR_SUCCESS) ? S_OK : E_FAIL);
@ -83,8 +101,8 @@ TF_UnregisterLangBarAddIn(
return E_INVALIDARG; return E_INVALIDARG;
} }
WCHAR szSubKey[MAX_PATH]; TCHAR szSubKey[MAX_PATH];
StringCchCopyW(szSubKey, _countof(szSubKey), L"SOFTWARE\\Microsoft\\CTF\\LangBarAddIn\\"); StringCchCopy(szSubKey, _countof(szSubKey), TEXT("SOFTWARE\\Microsoft\\CTF\\LangBarAddIn\\"));
CicRegKey regKey; CicRegKey regKey;
HKEY hBaseKey = ((dwFlags & 1) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER); HKEY hBaseKey = ((dwFlags & 1) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER);
@ -92,8 +110,8 @@ TF_UnregisterLangBarAddIn(
HRESULT hr = E_FAIL; HRESULT hr = E_FAIL;
if (error == ERROR_SUCCESS) if (error == ERROR_SUCCESS)
{ {
WCHAR szGUID[40]; TCHAR szGUID[40];
StringFromGUID2(rguid, szGUID, _countof(szGUID)); StringFromGUID2T(rguid, szGUID, _countof(szGUID));
regKey.RecurseDeleteKey(szGUID); regKey.RecurseDeleteKey(szGUID);
hr = S_OK; hr = S_OK;
} }

View file

@ -11,7 +11,7 @@ add_library(msutb MODULE
${SOURCE} ${SOURCE}
msutb.rc msutb.rc
${CMAKE_CURRENT_BINARY_DIR}/msutb.def) ${CMAKE_CURRENT_BINARY_DIR}/msutb.def)
set_module_type(msutb win32dll UNICODE) set_module_type(msutb win32dll)
add_dependencies(msutb msctf psdk) add_dependencies(msutb msctf psdk)
target_link_libraries(msutb wine uuid atl_classes) target_link_libraries(msutb wine uuid atl_classes)
add_importlibs(msutb user32 gdi32 advapi32 comctl32 msvcrt kernel32 ntdll) add_importlibs(msutb user32 gdi32 advapi32 comctl32 msvcrt kernel32 ntdll)

View file

@ -71,9 +71,9 @@ cicGetOSInfo(LPUINT puACP, LPDWORD pdwOSInfo)
*pdwOSInfo = 0; *pdwOSInfo = 0;
/* Check OS version info */ /* Check OS version info */
OSVERSIONINFOW VerInfo; OSVERSIONINFO VerInfo;
VerInfo.dwOSVersionInfoSize = sizeof(VerInfo); VerInfo.dwOSVersionInfoSize = sizeof(VerInfo);
GetVersionExW(&VerInfo); GetVersionEx(&VerInfo);
if (VerInfo.dwPlatformId == DLLVER_PLATFORM_NT) if (VerInfo.dwPlatformId == DLLVER_PLATFORM_NT)
{ {
*pdwOSInfo |= CIC_OSINFO_NT; *pdwOSInfo |= CIC_OSINFO_NT;
@ -113,7 +113,7 @@ cicGetOSInfo(LPUINT puACP, LPDWORD pdwOSInfo)
struct CicSystemModulePath struct CicSystemModulePath
{ {
WCHAR m_szPath[MAX_PATH + 2]; TCHAR m_szPath[MAX_PATH + 2];
SIZE_T m_cchPath; SIZE_T m_cchPath;
CicSystemModulePath() CicSystemModulePath()
@ -122,31 +122,31 @@ struct CicSystemModulePath
m_cchPath = 0; m_cchPath = 0;
} }
BOOL Init(_In_ LPCWSTR pszFileName, _In_ BOOL bSysWinDir); BOOL Init(_In_ LPCTSTR pszFileName, _In_ BOOL bSysWinDir);
}; };
// Get an instance handle that is already loaded // Get an instance handle that is already loaded
static inline HINSTANCE static inline HINSTANCE
cicGetSystemModuleHandle( cicGetSystemModuleHandle(
_In_ LPCWSTR pszFileName, _In_ LPCTSTR pszFileName,
_In_ BOOL bSysWinDir) _In_ BOOL bSysWinDir)
{ {
CicSystemModulePath ModPath; CicSystemModulePath ModPath;
if (!ModPath.Init(pszFileName, bSysWinDir)) if (!ModPath.Init(pszFileName, bSysWinDir))
return NULL; return NULL;
return GetModuleHandleW(ModPath.m_szPath); return GetModuleHandle(ModPath.m_szPath);
} }
// Load a system library // Load a system library
static inline HINSTANCE static inline HINSTANCE
cicLoadSystemLibrary( cicLoadSystemLibrary(
_In_ LPCWSTR pszFileName, _In_ LPCTSTR pszFileName,
_In_ BOOL bSysWinDir) _In_ BOOL bSysWinDir)
{ {
CicSystemModulePath ModPath; CicSystemModulePath ModPath;
if (!ModPath.Init(pszFileName, bSysWinDir)) if (!ModPath.Init(pszFileName, bSysWinDir))
return NULL; return NULL;
return ::LoadLibraryW(ModPath.m_szPath); return ::LoadLibrary(ModPath.m_szPath);
} }
#include <ndk/pstypes.h> /* for PROCESSINFOCLASS */ #include <ndk/pstypes.h> /* for PROCESSINFOCLASS */
@ -163,7 +163,7 @@ static inline BOOL cicIsWow64(VOID)
if (!s_fnNtQueryInformationProcess) if (!s_fnNtQueryInformationProcess)
{ {
HMODULE hNTDLL = cicGetSystemModuleHandle(L"ntdll.dll", FALSE); HMODULE hNTDLL = cicGetSystemModuleHandle(TEXT("ntdll.dll"), FALSE);
if (!hNTDLL) if (!hNTDLL)
return FALSE; return FALSE;
@ -184,38 +184,38 @@ static inline BOOL cicIsWow64(VOID)
inline BOOL inline BOOL
CicSystemModulePath::Init( CicSystemModulePath::Init(
_In_ LPCWSTR pszFileName, _In_ LPCTSTR pszFileName,
_In_ BOOL bSysWinDir) _In_ BOOL bSysWinDir)
{ {
SIZE_T cchPath; SIZE_T cchPath;
if (bSysWinDir) if (bSysWinDir)
{ {
// Usually C:\Windows or C:\ReactOS // Usually C:\Windows or C:\ReactOS
cchPath = ::GetSystemWindowsDirectoryW(m_szPath, _countof(m_szPath)); cchPath = ::GetSystemWindowsDirectory(m_szPath, _countof(m_szPath));
} }
else else
{ {
// Usually C:\Windows\system32 or C:\ReactOS\system32 // Usually C:\Windows\system32 or C:\ReactOS\system32
cchPath = ::GetSystemDirectoryW(m_szPath, _countof(m_szPath)); cchPath = ::GetSystemDirectory(m_szPath, _countof(m_szPath));
} }
m_szPath[_countof(m_szPath) - 1] = UNICODE_NULL; // Avoid buffer overrun m_szPath[_countof(m_szPath) - 1] = TEXT('\0'); // Avoid buffer overrun
if ((cchPath == 0) || (cchPath > _countof(m_szPath) - 2)) if ((cchPath == 0) || (cchPath > _countof(m_szPath) - 2))
goto Failure; goto Failure;
// Add backslash if necessary // Add backslash if necessary
if ((cchPath > 0) && (m_szPath[cchPath - 1] != L'\\')) if ((cchPath > 0) && (m_szPath[cchPath - 1] != TEXT('\\')))
{ {
m_szPath[cchPath + 0] = L'\\'; m_szPath[cchPath + 0] = TEXT('\\');
m_szPath[cchPath + 1] = UNICODE_NULL; m_szPath[cchPath + 1] = TEXT('\0');
} }
// Append pszFileName // Append pszFileName
if (FAILED(StringCchCatW(m_szPath, _countof(m_szPath), pszFileName))) if (FAILED(StringCchCat(m_szPath, _countof(m_szPath), pszFileName)))
goto Failure; goto Failure;
m_cchPath = wcslen(m_szPath); m_cchPath = _tcslen(m_szPath);
return TRUE; return TRUE;
Failure: Failure:
@ -254,7 +254,7 @@ cicRealCoCreateInstance(
if (!s_fnCoCreateInstance) if (!s_fnCoCreateInstance)
{ {
if (!s_hOle32) if (!s_hOle32)
s_hOle32 = cicLoadSystemLibrary(L"ole32.dll", FALSE); s_hOle32 = cicLoadSystemLibrary(TEXT("ole32.dll"), FALSE);
s_fnCoCreateInstance = (FN_CoCreateInstance)GetProcAddress(s_hOle32, "CoCreateInstance"); s_fnCoCreateInstance = (FN_CoCreateInstance)GetProcAddress(s_hOle32, "CoCreateInstance");
if (!s_fnCoCreateInstance) if (!s_fnCoCreateInstance)
return E_NOTIMPL; return E_NOTIMPL;

View file

@ -12,7 +12,7 @@
class CicEvent class CicEvent
{ {
HANDLE m_hEvent; HANDLE m_hEvent;
LPCWSTR m_pszName; LPCTSTR m_pszName;
public: public:
CicEvent() : m_hEvent(NULL), m_pszName(NULL) CicEvent() : m_hEvent(NULL), m_pszName(NULL)
@ -23,20 +23,20 @@ public:
Close(); Close();
} }
BOOL Create(LPSECURITY_ATTRIBUTES lpSA, LPCWSTR pszName) BOOL Create(LPSECURITY_ATTRIBUTES lpSA, LPCTSTR pszName)
{ {
if (pszName) if (pszName)
m_pszName = pszName; m_pszName = pszName;
if (!m_pszName) if (!m_pszName)
return FALSE; return FALSE;
m_hEvent = ::CreateEventW(lpSA, FALSE, FALSE, m_pszName); m_hEvent = ::CreateEvent(lpSA, FALSE, FALSE, m_pszName);
return (m_hEvent != NULL); return (m_hEvent != NULL);
} }
BOOL Open(LPCWSTR pszName) BOOL Open(LPCTSTR pszName)
{ {
if (pszName) if (pszName)
m_pszName = pszName; m_pszName = pszName;
m_hEvent = ::OpenEventW(EVENT_ALL_ACCESS, FALSE, m_pszName); m_hEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, m_pszName);
return (m_hEvent != NULL); return (m_hEvent != NULL);
} }
void Close() void Close()

View file

@ -15,7 +15,7 @@
class CicFileMappingStatic class CicFileMappingStatic
{ {
protected: protected:
LPCWSTR m_pszName; LPCTSTR m_pszName;
LPVOID m_pView; LPVOID m_pView;
HANDLE m_hMapping; HANDLE m_hMapping;
BOOL m_bCreated; BOOL m_bCreated;
@ -28,7 +28,7 @@ public:
CicFileMappingStatic() { } CicFileMappingStatic() { }
~CicFileMappingStatic() { } ~CicFileMappingStatic() { }
void Init(LPCWSTR pszName, CicMutex *pMutex); void Init(LPCTSTR pszName, CicMutex *pMutex);
LPVOID Create(LPSECURITY_ATTRIBUTES pSA, DWORD dwMaximumSizeLow, LPBOOL pbAlreadyExists); LPVOID Create(LPSECURITY_ATTRIBUTES pSA, DWORD dwMaximumSizeLow, LPBOOL pbAlreadyExists);
LPVOID Open(); LPVOID Open();
@ -43,14 +43,14 @@ public:
class CicFileMapping : public CCicFileMappingStatic class CicFileMapping : public CCicFileMappingStatic
{ {
public: public:
CicFileMapping(LPCWSTR pszName, CicMutex *pMutex); CicFileMapping(LPCTSTR pszName, CicMutex *pMutex);
virtual ~CicFileMapping() { Finalize(); } virtual ~CicFileMapping() { Finalize(); }
}; };
/******************************************************************************/ /******************************************************************************/
inline inline
CicFileMapping::CicFileMapping(LPCWSTR pszName, CicMutex *pMutex) CicFileMapping::CicFileMapping(LPCTSTR pszName, CicMutex *pMutex)
: m_pszName(NULL) : m_pszName(NULL)
, m_pView(NULL) , m_pView(NULL)
, m_hMapping(NULL) , m_hMapping(NULL)
@ -78,7 +78,7 @@ inline void CicFileMappingStatic::Close()
m_bCreated = FALSE; m_bCreated = FALSE;
} }
inline void CicFileMappingStatic::Init(LPCWSTR pszName, CicMutex *pMutex) inline void CicFileMappingStatic::Init(LPCTSTR pszName, CicMutex *pMutex)
{ {
if (pMutex) if (pMutex)
m_pMutex = pMutex; m_pMutex = pMutex;
@ -97,7 +97,7 @@ CicFileMappingStatic::Create(
if (!m_pszName) if (!m_pszName)
return NULL; return NULL;
m_hMapping = ::CreateFileMappingW(INVALID_HANDLE_VALUE, m_hMapping = ::CreateFileMapping(INVALID_HANDLE_VALUE,
pSA, pSA,
PAGE_READWRITE, PAGE_READWRITE,
0, 0,
@ -116,7 +116,7 @@ inline LPVOID CicFileMappingStatic::Open()
{ {
if (!m_pszName) if (!m_pszName)
return NULL; return NULL;
m_hMapping = ::OpenFileMappingW(FILE_MAP_ALL_ACCESS, FALSE, m_pszName); m_hMapping = ::OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, m_pszName);
if (!m_hMapping) if (!m_hMapping)
return NULL; return NULL;

View file

@ -23,9 +23,9 @@ public:
Uninit(); Uninit();
} }
void Init(LPSECURITY_ATTRIBUTES lpSA, LPCWSTR pszMutexName) void Init(LPSECURITY_ATTRIBUTES lpSA, LPCTSTR pszMutexName)
{ {
m_hMutex = ::CreateMutexW(lpSA, FALSE, pszMutexName); m_hMutex = ::CreateMutex(lpSA, FALSE, pszMutexName);
m_bInit = TRUE; m_bInit = TRUE;
} }
void Uninit() void Uninit()

View file

@ -23,43 +23,48 @@ public:
LSTATUS Open( LSTATUS Open(
HKEY hKey, HKEY hKey,
LPCWSTR lpSubKey, LPCTSTR lpSubKey,
REGSAM samDesired = KEY_READ); REGSAM samDesired = KEY_READ);
LSTATUS Create( LSTATUS Create(
HKEY hKey, HKEY hKey,
LPCWSTR lpSubKey, LPCTSTR lpSubKey,
LPWSTR lpClass = NULL, LPTSTR lpClass = NULL,
DWORD dwOptions = REG_OPTION_NON_VOLATILE, DWORD dwOptions = REG_OPTION_NON_VOLATILE,
REGSAM samDesired = KEY_ALL_ACCESS, REGSAM samDesired = KEY_ALL_ACCESS,
LPSECURITY_ATTRIBUTES lpSecurityAttributes = NULL, LPSECURITY_ATTRIBUTES lpSecurityAttributes = NULL,
LPDWORD pdwDisposition = NULL); LPDWORD pdwDisposition = NULL);
LSTATUS QueryDword(LPCWSTR pszValueName, LPDWORD pdwValue) LSTATUS QueryDword(LPCTSTR pszValueName, LPDWORD pdwValue)
{ {
DWORD cbData = sizeof(DWORD); DWORD cbData = sizeof(DWORD);
return ::RegQueryValueExW(m_hKey, pszValueName, 0, NULL, (LPBYTE)pdwValue, &cbData); return ::RegQueryValueEx(m_hKey, pszValueName, 0, NULL, (LPBYTE)pdwValue, &cbData);
} }
LSTATUS SetDword(LPCWSTR pszValueName, DWORD dwValue) LSTATUS SetDword(LPCTSTR pszValueName, DWORD dwValue)
{ {
return ::RegSetValueExW(m_hKey, pszValueName, 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(dwValue)); return ::RegSetValueEx(m_hKey, pszValueName, 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(dwValue));
} }
LSTATUS QuerySz(LPCWSTR pszValueName, LPWSTR pszValue, DWORD cchValueMax); LSTATUS QuerySz(LPCTSTR pszValueName, LPWSTR pszValue, DWORD cchValueMax);
LSTATUS SetSz(LPCWSTR pszValueName, LPCWSTR pszValue) LSTATUS SetSz(LPCTSTR pszValueName, LPCTSTR pszValue)
{
DWORD cbValue = (lstrlen(pszValue) + 1) * sizeof(TCHAR);
return ::RegSetValueEx(m_hKey, pszValueName, 0, REG_SZ, (LPBYTE)pszValue, cbValue);
}
LSTATUS SetSzW(LPCWSTR pszValueName, LPCWSTR pszValue)
{ {
DWORD cbValue = (lstrlenW(pszValue) + 1) * sizeof(WCHAR); DWORD cbValue = (lstrlenW(pszValue) + 1) * sizeof(WCHAR);
return ::RegSetValueExW(m_hKey, pszValueName, 0, REG_SZ, (LPBYTE)pszValue, cbValue); return ::RegSetValueExW(m_hKey, pszValueName, 0, REG_SZ, (LPBYTE)pszValue, cbValue);
} }
LSTATUS DeleteSubKey(LPCWSTR lpSubKey) LSTATUS DeleteSubKey(LPCTSTR lpSubKey)
{ {
return ::RegDeleteKeyW(m_hKey, lpSubKey); return ::RegDeleteKey(m_hKey, lpSubKey);
} }
LSTATUS RecurseDeleteKey(LPCWSTR lpSubKey); LSTATUS RecurseDeleteKey(LPCTSTR lpSubKey);
}; };
/******************************************************************************/ /******************************************************************************/
@ -77,11 +82,11 @@ CicRegKey::Close()
inline LSTATUS inline LSTATUS
CicRegKey::Open( CicRegKey::Open(
HKEY hKey, HKEY hKey,
LPCWSTR lpSubKey, LPCTSTR lpSubKey,
REGSAM samDesired) REGSAM samDesired)
{ {
HKEY hNewKey = NULL; HKEY hNewKey = NULL;
LSTATUS error = ::RegOpenKeyExW(hKey, lpSubKey, 0, samDesired, &hNewKey); LSTATUS error = ::RegOpenKeyEx(hKey, lpSubKey, 0, samDesired, &hNewKey);
if (error != ERROR_SUCCESS) if (error != ERROR_SUCCESS)
return error; return error;
@ -93,15 +98,15 @@ CicRegKey::Open(
inline LSTATUS inline LSTATUS
CicRegKey::Create( CicRegKey::Create(
HKEY hKey, HKEY hKey,
LPCWSTR lpSubKey, LPCTSTR lpSubKey,
LPWSTR lpClass, LPTSTR lpClass,
DWORD dwOptions, DWORD dwOptions,
REGSAM samDesired, REGSAM samDesired,
LPSECURITY_ATTRIBUTES lpSecurityAttributes, LPSECURITY_ATTRIBUTES lpSecurityAttributes,
LPDWORD pdwDisposition) LPDWORD pdwDisposition)
{ {
HKEY hNewKey = NULL; HKEY hNewKey = NULL;
LSTATUS error = ::RegCreateKeyExW(hKey, LSTATUS error = ::RegCreateKeyEx(hKey,
lpSubKey, lpSubKey,
0, 0,
lpClass, lpClass,
@ -119,12 +124,12 @@ CicRegKey::Create(
} }
inline LSTATUS inline LSTATUS
CicRegKey::QuerySz(LPCWSTR pszValueName, LPWSTR pszValue, DWORD cchValueMax) CicRegKey::QuerySz(LPCTSTR pszValueName, LPWSTR pszValue, DWORD cchValueMax)
{ {
DWORD cchSaveMax = cchValueMax; DWORD cchSaveMax = cchValueMax;
cchValueMax *= sizeof(WCHAR); cchValueMax *= sizeof(TCHAR);
LSTATUS error = ::RegQueryValueExW(m_hKey, pszValueName, 0, NULL, LSTATUS error = ::RegQueryValueEx(m_hKey, pszValueName, 0, NULL,
(LPBYTE)pszValue, &cchValueMax); (LPBYTE)pszValue, &cchValueMax);
if (cchSaveMax > 0) if (cchSaveMax > 0)
pszValue[(error == ERROR_SUCCESS) ? (cchSaveMax - 1) : 0] = UNICODE_NULL; pszValue[(error == ERROR_SUCCESS) ? (cchSaveMax - 1) : 0] = UNICODE_NULL;
@ -133,19 +138,19 @@ CicRegKey::QuerySz(LPCWSTR pszValueName, LPWSTR pszValue, DWORD cchValueMax)
} }
inline LSTATUS inline LSTATUS
CicRegKey::RecurseDeleteKey(LPCWSTR lpSubKey) CicRegKey::RecurseDeleteKey(LPCTSTR lpSubKey)
{ {
CicRegKey regKey; CicRegKey regKey;
LSTATUS error = regKey.Open(m_hKey, lpSubKey, KEY_READ | KEY_WRITE); LSTATUS error = regKey.Open(m_hKey, lpSubKey, KEY_READ | KEY_WRITE);
if (error != ERROR_SUCCESS) if (error != ERROR_SUCCESS)
return error; return error;
WCHAR szName[MAX_PATH]; TCHAR szName[MAX_PATH];
DWORD cchName; DWORD cchName;
do do
{ {
cchName = _countof(szName); cchName = _countof(szName);
error = ::RegEnumKeyExW(regKey, 0, szName, &cchName, NULL, NULL, NULL, NULL); error = ::RegEnumKeyEx(regKey, 0, szName, &cchName, NULL, NULL, NULL, NULL);
if (error != ERROR_SUCCESS) if (error != ERROR_SUCCESS)
break; break;