summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorAnyOldName3 <krizdjali+github@gmail.com>2018-05-15 23:43:35 +0100
committerAnyOldName3 <krizdjali+github@gmail.com>2018-05-15 23:43:35 +0100
commit8f905e1d498f0c264529737f4b8f7a47c0de59ee (patch)
treed2559884f689882ab488f518aedb7932a35ad03d /src/shared
parent2ee5f0e96dd6928c271e1b37cd1f77ddc456ef9c (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')
-rw-r--r--src/shared/util.cpp28
-rw-r--r--src/shared/util.h1
2 files changed, 29 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
diff --git a/src/shared/util.h b/src/shared/util.h
index 1e498059..75c382a7 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -45,6 +45,7 @@ std::wstring ToLower(const std::wstring &text);
bool CaseInsensitiveEqual(const std::wstring &lhs, const std::wstring &rhs);
VS_FIXEDFILEINFO GetFileVersion(const std::wstring &fileName);
+std::wstring GetFileVersionString(const std::wstring &fileName);
} // namespace MOShared