[email protected] | 90509cb | 2011-03-25 18:46:38 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | bcff05a | 2010-04-14 01:46:43 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #ifndef BASE_FILE_VERSION_INFO_WIN_H_ | ||||
6 | #define BASE_FILE_VERSION_INFO_WIN_H_ | ||||
[email protected] | bcff05a | 2010-04-14 01:46:43 | [diff] [blame] | 7 | |
fdoray | 5b7de9e9 | 2016-06-29 23:13:11 | [diff] [blame] | 8 | #include <windows.h> |
9 | |||||
10 | #include <stdint.h> | ||||
11 | |||||
dcheng | 093de9b | 2016-04-04 21:25:51 | [diff] [blame] | 12 | #include <memory> |
[email protected] | bcff05a | 2010-04-14 01:46:43 | [diff] [blame] | 13 | #include <string> |
fdoray | 5b7de9e9 | 2016-06-29 23:13:11 | [diff] [blame] | 14 | #include <vector> |
[email protected] | bcff05a | 2010-04-14 01:46:43 | [diff] [blame] | 15 | |
[email protected] | 0bea725 | 2011-08-05 15:34:00 | [diff] [blame] | 16 | #include "base/base_export.h" |
[email protected] | bcff05a | 2010-04-14 01:46:43 | [diff] [blame] | 17 | #include "base/file_version_info.h" |
Alan Screen | e93de3a | 2019-10-02 13:56:09 | [diff] [blame] | 18 | #include "base/version.h" |
[email protected] | bcff05a | 2010-04-14 01:46:43 | [diff] [blame] | 19 | |
20 | struct tagVS_FIXEDFILEINFO; | ||||
21 | typedef tagVS_FIXEDFILEINFO VS_FIXEDFILEINFO; | ||||
22 | |||||
mgiuca | 8137fc2 | 2015-05-07 02:20:31 | [diff] [blame] | 23 | class BASE_EXPORT FileVersionInfoWin : public FileVersionInfo { |
[email protected] | bcff05a | 2010-04-14 01:46:43 | [diff] [blame] | 24 | public: |
David Bienvenu | b4b441e | 2020-09-23 05:49:57 | [diff] [blame] | 25 | FileVersionInfoWin(const FileVersionInfoWin&) = delete; |
26 | FileVersionInfoWin& operator=(const FileVersionInfoWin&) = delete; | ||||
mgiuca | 8137fc2 | 2015-05-07 02:20:31 | [diff] [blame] | 27 | ~FileVersionInfoWin() override; |
[email protected] | bcff05a | 2010-04-14 01:46:43 | [diff] [blame] | 28 | |
29 | // Accessors to the different version properties. | ||||
30 | // Returns an empty string if the property is not found. | ||||
Jan Wilken Dörrie | 85285b0 | 2021-03-11 23:38:47 | [diff] [blame] | 31 | std::u16string company_name() override; |
32 | std::u16string company_short_name() override; | ||||
33 | std::u16string product_name() override; | ||||
34 | std::u16string product_short_name() override; | ||||
35 | std::u16string internal_name() override; | ||||
36 | std::u16string product_version() override; | ||||
37 | std::u16string special_build() override; | ||||
38 | std::u16string original_filename() override; | ||||
39 | std::u16string file_description() override; | ||||
40 | std::u16string file_version() override; | ||||
[email protected] | bcff05a | 2010-04-14 01:46:43 | [diff] [blame] | 41 | |
Lei Zhang | 4bb23de | 2019-10-04 16:17:08 | [diff] [blame] | 42 | // Lets you access other properties not covered above. |value| is only |
43 | // modified if GetValue() returns true. | ||||
Jan Wilken Dörrie | 85285b0 | 2021-03-11 23:38:47 | [diff] [blame] | 44 | bool GetValue(const char16_t* name, std::u16string* value) const; |
[email protected] | bcff05a | 2010-04-14 01:46:43 | [diff] [blame] | 45 | |
Jan Wilken Dörrie | 085b2aa | 2021-03-12 16:26:57 | [diff] [blame] | 46 | // Similar to GetValue but returns a std::u16string (empty string if the |
47 | // property does not exist). | ||||
Jan Wilken Dörrie | 85285b0 | 2021-03-11 23:38:47 | [diff] [blame] | 48 | std::u16string GetStringValue(const char16_t* name) const; |
[email protected] | bcff05a | 2010-04-14 01:46:43 | [diff] [blame] | 49 | |
Alan Screen | e93de3a | 2019-10-02 13:56:09 | [diff] [blame] | 50 | // Get file version number in dotted version format. |
51 | base::Version GetFileVersion() const; | ||||
[email protected] | bcff05a | 2010-04-14 01:46:43 | [diff] [blame] | 52 | |
David Benjamin | 04cc2b4 | 2019-01-29 05:30:33 | [diff] [blame] | 53 | // Behaves like CreateFileVersionInfo, but returns a FileVersionInfoWin. |
54 | static std::unique_ptr<FileVersionInfoWin> CreateFileVersionInfoWin( | ||||
55 | const base::FilePath& file_path); | ||||
56 | |||||
[email protected] | bcff05a | 2010-04-14 01:46:43 | [diff] [blame] | 57 | private: |
fdoray | 5b7de9e9 | 2016-06-29 23:13:11 | [diff] [blame] | 58 | friend FileVersionInfo; |
59 | |||||
60 | // |data| is a VS_VERSION_INFO resource. |language| and |code_page| are | ||||
61 | // extracted from the \VarFileInfo\Translation value of |data|. | ||||
62 | FileVersionInfoWin(std::vector<uint8_t>&& data, | ||||
63 | WORD language, | ||||
64 | WORD code_page); | ||||
65 | FileVersionInfoWin(void* data, WORD language, WORD code_page); | ||||
66 | |||||
67 | const std::vector<uint8_t> owned_data_; | ||||
68 | const void* const data_; | ||||
69 | const WORD language_; | ||||
70 | const WORD code_page_; | ||||
71 | |||||
Lei Zhang | 4bb23de | 2019-10-04 16:17:08 | [diff] [blame] | 72 | // This is a reference for a portion of |data_|. |
73 | const VS_FIXEDFILEINFO& fixed_file_info_; | ||||
[email protected] | bcff05a | 2010-04-14 01:46:43 | [diff] [blame] | 74 | }; |
75 | |||||
76 | #endif // BASE_FILE_VERSION_INFO_WIN_H_ |