diff options
| author | AnyOldName3 <krizdjali+github@gmail.com> | 2018-05-15 23:43:35 +0100 |
|---|---|---|
| committer | AnyOldName3 <krizdjali+github@gmail.com> | 2018-05-15 23:43:35 +0100 |
| commit | 8f905e1d498f0c264529737f4b8f7a47c0de59ee (patch) | |
| tree | d2559884f689882ab488f518aedb7932a35ad03d /src/shared/util.cpp | |
| parent | 2ee5f0e96dd6928c271e1b37cd1f77ddc456ef9c (diff) | |
Change how the VersionInfo object is created from version.rc such that non-release builds are possible and get labelled as such
Diffstat (limited to 'src/shared/util.cpp')
| -rw-r--r-- | src/shared/util.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/shared/util.cpp b/src/shared/util.cpp index 5491a9e6..008c5050 100644 --- a/src/shared/util.cpp +++ b/src/shared/util.cpp @@ -174,5 +174,33 @@ VS_FIXEDFILEINFO GetFileVersion(const std::wstring &fileName) }
}
+std::wstring GetFileVersionString(const std::wstring &fileName)
+{
+ DWORD handle = 0UL;
+ DWORD size = ::GetFileVersionInfoSizeW(fileName.c_str(), &handle);
+ if (size == 0) {
+ throw windows_error("failed to determine file version info size");
+ }
+
+ boost::scoped_array<char> buffer(new char[size]);
+ try {
+ handle = 0UL;
+ if (!::GetFileVersionInfoW(fileName.c_str(), handle, size, buffer.get())) {
+ throw windows_error("failed to determine file version info");
+ }
+
+ LPVOID strBuffer = nullptr;
+ UINT strLength = 0;
+ if (!::VerQueryValue(buffer.get(), L"\\StringFileInfo\\040904B0\\ProductVersion", &strBuffer, &strLength)) {
+ throw windows_error("failed to determine file version");
+ }
+
+ return std::wstring((LPCTSTR)strBuffer);
+ }
+ catch (...) {
+ throw;
+ }
+}
+
} // namespace MOShared
|
