From 8e7a3076bfba11f402e18f5bfff887a4fad2867c Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Wed, 4 Dec 2024 20:17:39 +0900 Subject: [PATCH] Simplify `ProgramFilesX86Cache` (#1131) The current implementation of ProgramFilesX86Cache::TryProgramFilesPath is unnecessarily complex. We can always use CSIDL_PROGRAM_FILESX86 not only within 64-bit processes but also within 32-bit processes. There must be no observable behavior change in this commit. This is a preparation to build Mozc as an ARM64 executable (#1130). See #1086 for how and when we can stop relying on this historical installation location. PiperOrigin-RevId: 702632385 --- src/base/system_util.cc | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/base/system_util.cc b/src/base/system_util.cc index ec1b70e0f..21ef2cc4e 100644 --- a/src/base/system_util.cc +++ b/src/base/system_util.cc @@ -376,24 +376,12 @@ class ProgramFilesX86Cache { path->clear(); wchar_t program_files_path_buffer[MAX_PATH] = {}; -#if defined(_M_X64) - // In 64-bit processes (such as Text Input Prosessor DLL for 64-bit apps), - // CSIDL_PROGRAM_FILES points 64-bit Program Files directory. In this case, - // we should use CSIDL_PROGRAM_FILESX86 to find server, renderer, and other - // binaries' path. + // For historical reasons Mozc executables have been installed under + // %ProgramFiles(x86)%. + // TODO(https://github.com/google/mozc/issues/1086): Stop using "(x86)". const HRESULT result = ::SHGetFolderPathW(nullptr, CSIDL_PROGRAM_FILESX86, nullptr, SHGFP_TYPE_CURRENT, program_files_path_buffer); -#elif defined(_M_IX86) - // In 32-bit processes (such as server, renderer, and other binaries), - // CSIDL_PROGRAM_FILES always points 32-bit Program Files directory - // even if they are running in 64-bit Windows. - const HRESULT result = - ::SHGetFolderPathW(nullptr, CSIDL_PROGRAM_FILES, nullptr, - SHGFP_TYPE_CURRENT, program_files_path_buffer); -#else // !_M_X64 && !_M_IX86 -#error "Unsupported CPU architecture" -#endif // _M_X64, _M_IX86, and others if (FAILED(result)) { return result; }