I need to get the version information of a DLL file I created in Visual Studio 2008 C++. How do I get it?
If you reference the dll in Visual Studio right click it (in ProjectName/References folder) and select "Properties" you have "Version" and "Runtime Version" there. In File Explorer when you right click the dll file and select properties there is a "File Version" and "Product Version" there.
You can use the FileVersionInfo. FileVersion property with the Get-Command to get the file version in PowerShell. The following command gets the file version number of a file C:\Windows\System32\ActionCenter. dll .
The easiest way is to use the GetFileVersionInfoEx or GetFileVersionInfo API functions.
Thanks for the answers.
This worked for me:
WCHAR fileName[_MAX_PATH];
DWORD size = GetModuleFileName(g_dllHandle, fileName, _MAX_PATH);
fileName[size] = NULL;
DWORD handle = 0;
size = GetFileVersionInfoSize(fileName, &handle);
BYTE* versionInfo = new BYTE[size];
if (!GetFileVersionInfo(fileName, handle, size, versionInfo))
{
delete[] versionInfo;
return;
}
// we have version information
UINT len = 0;
VS_FIXEDFILEINFO* vsfi = NULL;
VerQueryValue(versionInfo, L"\\", (void**)&vsfi, &len);
aVersion[0] = HIWORD(vsfi->dwFileVersionMS);
aVersion[1] = LOWORD(vsfi->dwFileVersionMS);
aVersion[2] = HIWORD(vsfi->dwFileVersionLS);
aVersion[3] = LOWORD(vsfi->dwFileVersionLS);
delete[] versionInfo;
If you want programmatic access, see Version Information in MSDN for the APIs and data structures you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With