file_version_info.h 2.4 KB

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