I need to get the version information of a DLL file I created in Visual Studio 2008 C++. How do I get it?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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;
回答2:
If you want programmatic access, see Version Information in MSDN for the APIs and data structures you need.
回答3:
Looks like you need to access the VS_VERSION_INFO resource; http://www.microsoft.com/msj/0498/c0498.aspx
回答4:
It should be there in the properties (version tab) when you open it in windows explorer