| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/file_version_info_win.h" | 5 #include "base/file_version_info_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_version_info.h" | 10 #include "base/file_version_info.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 FileVersionInfoWin::~FileVersionInfoWin() { | 24 FileVersionInfoWin::~FileVersionInfoWin() { |
| 25 DCHECK(data_.get()); | 25 DCHECK(data_.get()); |
| 26 } | 26 } |
| 27 | 27 |
| 28 typedef struct { | 28 typedef struct { |
| 29 WORD language; | 29 WORD language; |
| 30 WORD code_page; | 30 WORD code_page; |
| 31 } LanguageAndCodePage; | 31 } LanguageAndCodePage; |
| 32 | 32 |
| 33 // static | 33 // static |
| 34 FileVersionInfo* FileVersionInfo::CreateFileVersionInfoForCurrentModule() { | 34 FileVersionInfo* FileVersionInfo::CreateFileVersionInfoForModule( |
| 35 FilePath app_path; | 35 HMODULE module) { |
| 36 if (!PathService::Get(base::FILE_MODULE, &app_path)) | 36 // Note that the use of MAX_PATH is basically in line with what we do for |
| 37 // all registered paths (PathProviderWin). |
| 38 wchar_t system_buffer[MAX_PATH]; |
| 39 system_buffer[0] = 0; |
| 40 if (!GetModuleFileName(module, system_buffer, MAX_PATH)) |
| 37 return NULL; | 41 return NULL; |
| 38 | 42 |
| 43 FilePath app_path(system_buffer); |
| 39 return CreateFileVersionInfo(app_path); | 44 return CreateFileVersionInfo(app_path); |
| 40 } | 45 } |
| 41 | 46 |
| 42 // static | 47 // static |
| 43 FileVersionInfo* FileVersionInfo::CreateFileVersionInfo( | 48 FileVersionInfo* FileVersionInfo::CreateFileVersionInfo( |
| 44 const FilePath& file_path) { | 49 const FilePath& file_path) { |
| 45 base::ThreadRestrictions::AssertIOAllowed(); | 50 base::ThreadRestrictions::AssertIOAllowed(); |
| 46 | 51 |
| 47 DWORD dummy; | 52 DWORD dummy; |
| 48 const wchar_t* path = file_path.value().c_str(); | 53 const wchar_t* path = file_path.value().c_str(); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 return false; | 178 return false; |
| 174 } | 179 } |
| 175 | 180 |
| 176 std::wstring FileVersionInfoWin::GetStringValue(const wchar_t* name) { | 181 std::wstring FileVersionInfoWin::GetStringValue(const wchar_t* name) { |
| 177 std::wstring str; | 182 std::wstring str; |
| 178 if (GetValue(name, &str)) | 183 if (GetValue(name, &str)) |
| 179 return str; | 184 return str; |
| 180 else | 185 else |
| 181 return L""; | 186 return L""; |
| 182 } | 187 } |
| OLD | NEW |