How to get the version information of a DLL file in C++

前端 未结 4 2142
孤独总比滥情好
孤独总比滥情好 2020-12-09 05:18

I need to get the version information of a DLL file I created in Visual Studio 2008 C++. How do I get it?

相关标签:
4条回答
  • 2020-12-09 05:32

    If you want programmatic access, see Version Information in MSDN for the APIs and data structures you need.

    0 讨论(0)
  • 2020-12-09 05:44

    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;
    
    0 讨论(0)
  • 2020-12-09 05:48

    It should be there in the properties (version tab) when you open it in windows explorer

    0 讨论(0)
  • 2020-12-09 05:49

    Looks like you need to access the VS_VERSION_INFO resource; http://www.microsoft.com/msj/0498/c0498.aspx

    0 讨论(0)
提交回复
热议问题