MCPcopy Create free account
hub / github.com/ModOrganizer2/modorganizer / GetFileVersionString

Function GetFileVersionString

src/shared/util.cpp:183–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181}
182
183std::wstring GetFileVersionString(const std::wstring& fileName)
184{
185 DWORD handle = 0UL;
186 DWORD size = ::GetFileVersionInfoSizeW(fileName.c_str(), &handle);
187 if (size == 0) {
188 throw windows_error("failed to determine file version info size");
189 }
190
191 boost::scoped_array<char> buffer(new char[size]);
192 try {
193 handle = 0UL;
194 if (!::GetFileVersionInfoW(fileName.c_str(), handle, size, buffer.get())) {
195 throw windows_error("failed to determine file version info");
196 }
197
198 LPVOID strBuffer = nullptr;
199 UINT strLength = 0;
200 if (!::VerQueryValue(buffer.get(), L"\\StringFileInfo\\040904B0\\ProductVersion",
201 &strBuffer, &strLength)) {
202 throw windows_error("failed to determine file version");
203 }
204
205 return std::wstring((LPCTSTR)strBuffer);
206 } catch (...) {
207 throw;
208 }
209}
210
211VersionInfo createVersionInfo()
212{

Callers 1

createVersionInfoFunction · 0.85

Calls 2

windows_errorClass · 0.85
getMethod · 0.45

Tested by

no test coverage detected