| 28 | } |
| 29 | |
| 30 | std::string GetVersionFromResource(const std::string& filePath) { |
| 31 | char modulePath[MAX_PATH] = { 0 }; |
| 32 | strcpy_s(modulePath, filePath.c_str()); |
| 33 | DWORD dummy; |
| 34 | DWORD size = GetFileVersionInfoSizeA(modulePath, &dummy); |
| 35 | if (size == 0) |
| 36 | return ""; |
| 37 | std::vector<char> data(size); |
| 38 | if (!GetFileVersionInfoA(modulePath, 0, size, data.data())) |
| 39 | return ""; |
| 40 | VS_FIXEDFILEINFO* fileInfo = nullptr; |
| 41 | UINT len = 0; |
| 42 | if (VerQueryValueA(data.data(), "\\", (LPVOID*)&fileInfo, &len) && fileInfo) { |
| 43 | int major = HIWORD(fileInfo->dwFileVersionMS); |
| 44 | int minor = LOWORD(fileInfo->dwFileVersionMS); |
| 45 | int build = HIWORD(fileInfo->dwFileVersionLS); |
| 46 | int revision = LOWORD(fileInfo->dwFileVersionLS); |
| 47 | char versionStr[128]; |
| 48 | sprintf_s(versionStr, "%d.%d.%d.%d", major, minor, build, revision); |
| 49 | return versionStr; |
| 50 | } |
| 51 | return ""; |
| 52 | } |
| 53 | |
| 54 | std::string GetVersionFromFiles(const std::string& filePath) { |
| 55 | char modulePath[MAX_PATH] = { 0 }; |
no outgoing calls
no test coverage detected