heres an example in c++ btw
Code:
FileVersion* GetFileVer()
{
CHAR dllPath[MAX_PATH] = { 0 };
GetModuleFileName(GetModuleHandleW(nullptr), reinterpret_cast<LPWSTR>(dllPath), _countof(dllPath));
DWORD verHandle = 0;
UINT size = 0;
LPBYTE lpBuffer = nullptr;
const auto verSize = GetFileVersionInfoSize(reinterpret_cast<LPWSTR>(dllPath), &verHandle);
if (verSize != NULL)
{
const auto verData = new char[verSize];
if (GetFileVersionInfo(reinterpret_cast<LPWSTR>(dllPath), verHandle, verSize, verData) && VerQueryValue(verData, L"\\", reinterpret_cast<VOID FAR * FAR*>(&lpBuffer), &size))
{
if (size)
{
const auto verInfo = reinterpret_cast<VS_FIXEDFILEINFO*>(lpBuffer);
if (verInfo->dwSignature == 0xfeef04bd)
{
const auto x = new FileVersion;
x->major = static_cast<int>(verInfo->dwFileVersionMS) >> 16 & 0xffff;
x->minor = static_cast<int>(verInfo->dwFileVersionMS) >> 0 & 0xffff;
x->bug_fix = static_cast<int>(verInfo->dwFileVersionLS) >> 16 & 0xffff;
x->build_number = static_cast<int>(verInfo->dwFileVersionLS) >> 0 & 0xffff;
return x;
}
}
}
delete[] verData;
}
return nullptr;
}
Code:
struct FileVersion final
{
int32_t major;
int32_t minor;
int32_t bug_fix;
int32_t build_number;
};
Code:
const auto fv = GetFileVer();
std::stringstream stringStream;
stringStream << fv->major << "." << fv->minor << "." << fv->bug_fix << "." << fv->build_number;
const auto version(stringStream.str());
WowVersion = version.c_str();
would output a string "1.13.3.32887" for example