| 181 | } |
| 182 | |
| 183 | std::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 | |
| 211 | VersionInfo createVersionInfo() |
| 212 | { |
no test coverage detected