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 return NULL; | 37 // all registered paths (PathProviderWin). |
38 wchar_t system_buffer[MAX_PATH]; | |
39 system_buffer[0] = 0; | |
40 GetModuleFileName(module, system_buffer, MAX_PATH); | |
wtc
2011/04/22 20:00:09
Should we check if GetModuleFileName fails (return
rvargas (doing something else)
2011/04/22 21:40:05
Done.
| |
41 FilePath app_path(system_buffer); | |
38 | 42 |
39 return CreateFileVersionInfo(app_path); | 43 return CreateFileVersionInfo(app_path); |
40 } | 44 } |
41 | 45 |
42 // static | 46 // static |
43 FileVersionInfo* FileVersionInfo::CreateFileVersionInfo( | 47 FileVersionInfo* FileVersionInfo::CreateFileVersionInfo( |
44 const FilePath& file_path) { | 48 const FilePath& file_path) { |
45 base::ThreadRestrictions::AssertIOAllowed(); | 49 base::ThreadRestrictions::AssertIOAllowed(); |
46 | 50 |
47 DWORD dummy; | 51 DWORD dummy; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 return false; | 177 return false; |
174 } | 178 } |
175 | 179 |
176 std::wstring FileVersionInfoWin::GetStringValue(const wchar_t* name) { | 180 std::wstring FileVersionInfoWin::GetStringValue(const wchar_t* name) { |
177 std::wstring str; | 181 std::wstring str; |
178 if (GetValue(name, &str)) | 182 if (GetValue(name, &str)) |
179 return str; | 183 return str; |
180 else | 184 else |
181 return L""; | 185 return L""; |
182 } | 186 } |
OLD | NEW |