file_version_info_win.h 2.5 KB

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