Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify ProgramFilesX86Cache::TryProgramFilesPath #1131

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 3 additions & 15 deletions src/base/system_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down