blob: e72a597584fe3773725a580b8bca355fc84efab4 [file] [log] [blame]
[email protected]90509cb2011-03-25 18:46:381// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]bcff05a2010-04-14 01:46:432// 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]bcff05a2010-04-14 01:46:437
fdoray5b7de9e92016-06-29 23:13:118#include <windows.h>
9
10#include <stdint.h>
11
dcheng093de9b2016-04-04 21:25:5112#include <memory>
[email protected]bcff05a2010-04-14 01:46:4313#include <string>
fdoray5b7de9e92016-06-29 23:13:1114#include <vector>
[email protected]bcff05a2010-04-14 01:46:4315
[email protected]0bea7252011-08-05 15:34:0016#include "base/base_export.h"
[email protected]bcff05a2010-04-14 01:46:4317#include "base/file_version_info.h"
Alan Screene93de3a2019-10-02 13:56:0918#include "base/version.h"
[email protected]bcff05a2010-04-14 01:46:4319
20struct tagVS_FIXEDFILEINFO;
21typedef tagVS_FIXEDFILEINFO VS_FIXEDFILEINFO;
22
mgiuca8137fc22015-05-07 02:20:3123class BASE_EXPORT FileVersionInfoWin : public FileVersionInfo {
[email protected]bcff05a2010-04-14 01:46:4324 public:
David Bienvenub4b441e2020-09-23 05:49:5725 FileVersionInfoWin(const FileVersionInfoWin&) = delete;
26 FileVersionInfoWin& operator=(const FileVersionInfoWin&) = delete;
mgiuca8137fc22015-05-07 02:20:3127 ~FileVersionInfoWin() override;
[email protected]bcff05a2010-04-14 01:46:4328
29 // Accessors to the different version properties.
30 // Returns an empty string if the property is not found.
Jan Wilken Dörrie85285b02021-03-11 23:38:4731 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]bcff05a2010-04-14 01:46:4341
Lei Zhang4bb23de2019-10-04 16:17:0842 // Lets you access other properties not covered above. |value| is only
43 // modified if GetValue() returns true.
Jan Wilken Dörrie85285b02021-03-11 23:38:4744 bool GetValue(const char16_t* name, std::u16string* value) const;
[email protected]bcff05a2010-04-14 01:46:4345
Jan Wilken Dörrie085b2aa2021-03-12 16:26:5746 // Similar to GetValue but returns a std::u16string (empty string if the
47 // property does not exist).
Jan Wilken Dörrie85285b02021-03-11 23:38:4748 std::u16string GetStringValue(const char16_t* name) const;
[email protected]bcff05a2010-04-14 01:46:4349
Alan Screene93de3a2019-10-02 13:56:0950 // Get file version number in dotted version format.
51 base::Version GetFileVersion() const;
[email protected]bcff05a2010-04-14 01:46:4352
David Benjamin04cc2b42019-01-29 05:30:3353 // Behaves like CreateFileVersionInfo, but returns a FileVersionInfoWin.
54 static std::unique_ptr<FileVersionInfoWin> CreateFileVersionInfoWin(
55 const base::FilePath& file_path);
56
[email protected]bcff05a2010-04-14 01:46:4357 private:
fdoray5b7de9e92016-06-29 23:13:1158 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 Zhang4bb23de2019-10-04 16:17:0872 // This is a reference for a portion of |data_|.
73 const VS_FIXEDFILEINFO& fixed_file_info_;
[email protected]bcff05a2010-04-14 01:46:4374};
75
76#endif // BASE_FILE_VERSION_INFO_WIN_H_