我需要获取我在Visual Studio 2008 C++中创建的DLL文件的版本信息.我怎么得到它?
谢谢你的回答.
这对我有用:
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;
如果您需要编程访问,请参阅MSDN中的版本信息以获取所需的API和数据结构.