MCPcopy Create free account
hub / github.com/Soreepeong/XivAlexander / FormatModuleVersionString

Method FormatModuleVersionString

XivAlexanderCommon/Utils/Win32.cpp:46–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46std::pair<std::string, std::string> Utils::Win32::FormatModuleVersionString(const void* pBlock) {
47 UINT size = 0;
48 LPVOID lpBuffer = nullptr;
49 if (!VerQueryValueW(pBlock, L"\\", &lpBuffer, &size))
50 throw std::runtime_error("Failed to query version information.");
51 const VS_FIXEDFILEINFO& versionInfo = *static_cast<const VS_FIXEDFILEINFO*>(lpBuffer);
52 if (versionInfo.dwSignature != 0xfeef04bd)
53 throw std::runtime_error("Invalid version info found.");
54 return std::make_pair<>(
55 std::format("{}.{}.{}.{}",
56 (versionInfo.dwFileVersionMS >> 16) & 0xFFFF,
57 (versionInfo.dwFileVersionMS >> 0) & 0xFFFF,
58 (versionInfo.dwFileVersionLS >> 16) & 0xFFFF,
59 (versionInfo.dwFileVersionLS >> 0) & 0xFFFF),
60 std::format("{}.{}.{}.{}",
61 (versionInfo.dwProductVersionMS >> 16) & 0xFFFF,
62 (versionInfo.dwProductVersionMS >> 0) & 0xFFFF,
63 (versionInfo.dwProductVersionLS >> 16) & 0xFFFF,
64 (versionInfo.dwProductVersionLS >> 0) & 0xFFFF));
65}
66
67std::pair<std::string, std::string> Utils::Win32::FormatModuleVersionString(const std::filesystem::path& path) {
68 const auto pathw = path.wstring();

Callers

nothing calls this directly

Calls 3

ErrorClass · 0.85
GlobalResourceClass · 0.85
emptyMethod · 0.80

Tested by

no test coverage detected