file_version_info_win.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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
  3. // found in the LICENSE file.
  4. #ifndef BASE_FILE_VERSION_INFO_WIN_H_
  5. #define BASE_FILE_VERSION_INFO_WIN_H_
  6. #include <windows.h>
  7. #include <stdint.h>
  8. #include <memory>
  9. #include <string>
  10. #include <vector>
  11. #include "base/base_export.h"
  12. #include "base/file_version_info.h"
  13. #include "base/version.h"
  14. struct tagVS_FIXEDFILEINFO;
  15. typedef tagVS_FIXEDFILEINFO VS_FIXEDFILEINFO;
  16. class BASE_EXPORT FileVersionInfoWin : public FileVersionInfo {
  17. public:
  18. FileVersionInfoWin(const FileVersionInfoWin&) = delete;
  19. FileVersionInfoWin& operator=(const FileVersionInfoWin&) = delete;
  20. ~FileVersionInfoWin() override;
  21. // Accessors to the different version properties.
  22. // Returns an empty string if the property is not found.
  23. base::string16 company_name() override;
  24. base::string16 company_short_name() override;
  25. base::string16 product_name() override;
  26. base::string16 product_short_name() override;
  27. base::string16 internal_name() override;
  28. base::string16 product_version() override;
  29. base::string16 special_build() override;
  30. base::string16 original_filename() override;
  31. base::string16 file_description() override;
  32. base::string16 file_version() override;
  33. // Lets you access other properties not covered above. |value| is only
  34. // modified if GetValue() returns true.
  35. bool GetValue(const base::char16* name, base::string16* value) const;
  36. // Similar to GetValue but returns a string16 (empty string if the property
  37. // does not exist).
  38. base::string16 GetStringValue(const base::char16* name) const;
  39. // Get file version number in dotted version format.
  40. base::Version GetFileVersion() const;
  41. // Behaves like CreateFileVersionInfo, but returns a FileVersionInfoWin.
  42. static std::unique_ptr<FileVersionInfoWin> CreateFileVersionInfoWin(
  43. const base::FilePath& file_path);
  44. private:
  45. friend FileVersionInfo;
  46. // |data| is a VS_VERSION_INFO resource. |language| and |code_page| are
  47. // extracted from the \VarFileInfo\Translation value of |data|.
  48. FileVersionInfoWin(std::vector<uint8_t>&& data,
  49. WORD language,
  50. WORD code_page);
  51. FileVersionInfoWin(void* data, WORD language, WORD code_page);
  52. const std::vector<uint8_t> owned_data_;
  53. const void* const data_;
  54. const WORD language_;
  55. const WORD code_page_;
  56. // This is a reference for a portion of |data_|.
  57. const VS_FIXEDFILEINFO& fixed_file_info_;
  58. };
  59. #endif // BASE_FILE_VERSION_INFO_WIN_H_