F4MP/tiltedcode/Code/immersive_launcher/utils/FileVersion.inl
Jous99 37b16f1547 code upload
codigo original de f4mp y tilted para referencias
2026-01-06 18:45:00 +01:00

34 lines
1.1 KiB
C++

#pragma once
#include <optional>
#include <Memory.hpp>
#include <Windows.h>
inline TiltedPhoques::String QueryFileVersion(const wchar_t* acpPath)
{
// check if viable
if (DWORD infoSize = GetFileVersionInfoSizeW(acpPath, nullptr))
{
auto buffer = TiltedPhoques::MakeUnique<uint8_t[]>(infoSize);
if (GetFileVersionInfoW(acpPath, 0, infoSize, buffer.get()))
{
char* productVersion = nullptr;
DWORD productVersionLen = 0;
if (VerQueryValue(buffer.get(), "\\StringFileInfo\\040904B0\\ProductVersion", (void**)&productVersion,
(PUINT)&productVersionLen) &&
productVersionLen && productVersion)
{
return productVersion;
}
if (VerQueryValueA(buffer.get(), "\\StringFileInfo\\040904B0\\FileVersion", (LPVOID*)&productVersion,
(PUINT)&productVersionLen) &&
productVersionLen && productVersion && *productVersion)
{
return productVersion;
}
}
}
return {};
}