file_version_info.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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_H_
  5. #define BASE_FILE_VERSION_INFO_H_
  6. #include <memory>
  7. #include <string>
  8. #include "build/build_config.h"
  9. #include "base/base_export.h"
  10. #if BUILDFLAG(IS_WIN)
  11. #include <windows.h>
  12. #endif
  13. namespace base {
  14. class FilePath;
  15. }
  16. // Provides an interface for accessing the version information for a file. This
  17. // is the information you access when you select a file in the Windows Explorer,
  18. // right-click select Properties, then click the Version tab, and on the Mac
  19. // when you select a file in the Finder and do a Get Info.
  20. //
  21. // This list of properties is straight out of Win32's VerQueryValue
  22. // <http://msdn.microsoft.com/en-us/library/ms647464.aspx> and the Mac
  23. // version returns values from the Info.plist as appropriate. TODO(avi): make
  24. // this a less-obvious Windows-ism.
  25. class BASE_EXPORT FileVersionInfo {
  26. public:
  27. virtual ~FileVersionInfo() {}
  28. #if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_APPLE)
  29. // Creates a FileVersionInfo for the specified path. Returns nullptr if
  30. // something goes wrong (typically the file does not exit or cannot be
  31. // opened).
  32. static std::unique_ptr<FileVersionInfo> CreateFileVersionInfo(
  33. const base::FilePath& file_path);
  34. #endif // BUILDFLAG(IS_WIN) || BUILDFLAG(IS_APPLE)
  35. #if BUILDFLAG(IS_WIN)
  36. // Creates a FileVersionInfo for the specified module. Returns nullptr in
  37. // case of error.
  38. static std::unique_ptr<FileVersionInfo> CreateFileVersionInfoForModule(
  39. HMODULE module);
  40. #else
  41. // Creates a FileVersionInfo for the current module. Returns nullptr in case
  42. // of error.
  43. static std::unique_ptr<FileVersionInfo>
  44. CreateFileVersionInfoForCurrentModule();
  45. #endif // BUILDFLAG(IS_WIN)
  46. // Accessors to the different version properties.
  47. // Returns an empty string if the property is not found.
  48. virtual std::u16string company_name() = 0;
  49. virtual std::u16string company_short_name() = 0;
  50. virtual std::u16string product_name() = 0;
  51. virtual std::u16string product_short_name() = 0;
  52. virtual std::u16string internal_name() = 0;
  53. virtual std::u16string product_version() = 0;
  54. virtual std::u16string special_build() = 0;
  55. virtual std::u16string original_filename() = 0;
  56. virtual std::u16string file_description() = 0;
  57. virtual std::u16string file_version() = 0;
  58. };
  59. #endif // BASE_FILE_VERSION_INFO_H_