I have cpp window dll that has a resource file containing a version string. I thought this version can be retrieved by the following logic:
// Read version from resource file
HMODULE hModule = GetModuleHandle(NULL);
HRSRC hVersion = FindResource(hModule, MAKEINTRESOURCE(VS_VERSION_INFO), RT_VERSION);
// Convert version info to string
if (hVersion) {
HGLOBAL hGlobal = LoadResource(hModule, hVersion);
if (hGlobal) {
LPVOID lpVersion = LockResource(hGlobal);
if (lpVersion) {
VS_FIXEDFILEINFO* pFileInfo = nullptr;
UINT dwLen = 0;
if (VerQueryValue(lpVersion, L"\\", (LPVOID*)&pFileInfo, &dwLen) && pFileInfo) {
WORD major = HIWORD(pFileInfo->dwFileVersionMS);
WORD minor = LOWORD(pFileInfo->dwFileVersionMS);
WORD build = HIWORD(pFileInfo->dwFileVersionLS);
WORD revision = LOWORD(pFileInfo->dwFileVersionLS);
string version = std::format("{}.{}.{}.{}", major, minor, build, revision);
logInfo(LOG_TITLE, std::format("Version: [{}]", version));
return version;
}
}
}
}
NOW THE FUNNY PART
I call the exported dll-methods from JAVA (via JNA) to query this version-string, so far so good:
BUT the version I get is the version from the Java-Runtime and NOT from the dll-resource file.
Does anybody has an idea how I can retrieve the version string from a resource file containing in the cpp-dll project, where this dll has exported methods to query exactly this version string. Thanx.
