1 // Copyright 2011 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef BASE_FILE_VERSION_INFO_WIN_H_
6 #define BASE_FILE_VERSION_INFO_WIN_H_
16 #include "base/base_export.h"
17 #include "base/file_version_info.h"
18 #include "base/memory/raw_ptr.h"
19 #include "base/memory/raw_ref.h"
20 #include "base/version.h"
22 struct tagVS_FIXEDFILEINFO;
23 typedef tagVS_FIXEDFILEINFO VS_FIXEDFILEINFO;
25 class BASE_EXPORT FileVersionInfoWin : public FileVersionInfo {
27 FileVersionInfoWin(const FileVersionInfoWin&) = delete;
28 FileVersionInfoWin& operator=(const FileVersionInfoWin&) = delete;
29 ~FileVersionInfoWin() override;
31 // Accessors to the different version properties.
32 // Returns an empty string if the property is not found.
33 std::u16string company_name() override;
34 std::u16string company_short_name() override;
35 std::u16string product_name() override;
36 std::u16string product_short_name() override;
37 std::u16string internal_name() override;
38 std::u16string product_version() override;
39 std::u16string special_build() override;
40 std::u16string original_filename() override;
41 std::u16string file_description() override;
42 std::u16string file_version() override;
44 // Lets you access other properties not covered above. |value| is only
45 // modified if GetValue() returns true.
46 bool GetValue(const char16_t* name, std::u16string* value) const;
48 // Similar to GetValue but returns a std::u16string (empty string if the
49 // property does not exist).
50 std::u16string GetStringValue(const char16_t* name) const;
52 // Get file version number in dotted version format.
53 base::Version GetFileVersion() const;
55 // Behaves like CreateFileVersionInfo, but returns a FileVersionInfoWin.
56 static std::unique_ptr<FileVersionInfoWin> CreateFileVersionInfoWin(
57 const base::FilePath& file_path);
60 friend FileVersionInfo;
62 // |data| is a VS_VERSION_INFO resource. |language| and |code_page| are
63 // extracted from the \VarFileInfo\Translation value of |data|.
64 FileVersionInfoWin(std::vector<uint8_t>&& data,
67 FileVersionInfoWin(void* data, WORD language, WORD code_page);
69 const std::vector<uint8_t> owned_data_;
70 const raw_ptr<const void> data_;
72 const WORD code_page_;
74 // This is a reference for a portion of |data_|.
75 const raw_ref<const VS_FIXEDFILEINFO> fixed_file_info_;
78 #endif // BASE_FILE_VERSION_INFO_WIN_H_