OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/public/common/registry_utils_win.h" |
| 6 |
| 7 #include "base/files/file_path.h" |
| 8 #include "base/win/registry.h" |
| 9 #include "base/win/windows_version.h" |
| 10 |
| 11 namespace content { |
| 12 |
| 13 const base::char16 kRegistryAppsKey[] = |
| 14 L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths"; |
| 15 const base::char16 kRegistryPath[] = L"Path"; |
| 16 |
| 17 const base::char16 kRegistryAcrobat[] = L"Acrobat.exe"; |
| 18 const base::char16 kRegistryAcrobatReader[] = L"AcroRd32.exe"; |
| 19 |
| 20 bool GetInstalledPath(const base::char16* app, base::FilePath* out) { |
| 21 base::string16 reg_path(kRegistryAppsKey); |
| 22 reg_path.append(L"\\"); |
| 23 reg_path.append(app); |
| 24 |
| 25 base::win::RegKey hkcu_key(HKEY_CURRENT_USER, reg_path.c_str(), KEY_READ); |
| 26 base::string16 path; |
| 27 // As of Win7 AppPaths can also be registered in HKCU: http://goo.gl/UgFOf. |
| 28 if (base::win::GetVersion() >= base::win::VERSION_WIN7 && |
| 29 hkcu_key.ReadValue(kRegistryPath, &path) == ERROR_SUCCESS) { |
| 30 *out = base::FilePath(path); |
| 31 return true; |
| 32 } else { |
| 33 base::win::RegKey hklm_key(HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_READ); |
| 34 if (hklm_key.ReadValue(kRegistryPath, &path) == ERROR_SUCCESS) { |
| 35 *out = base::FilePath(path); |
| 36 return true; |
| 37 } |
| 38 } |
| 39 |
| 40 return false; |
| 41 } |
| 42 |
| 43 } // namespace content |
OLD | NEW |