1. <i id='A9lK9'><tr id='A9lK9'><dt id='A9lK9'><q id='A9lK9'><span id='A9lK9'><b id='A9lK9'><form id='A9lK9'><ins id='A9lK9'></ins><ul id='A9lK9'></ul><sub id='A9lK9'></sub></form><legend id='A9lK9'></legend><bdo id='A9lK9'><pre id='A9lK9'><center id='A9lK9'></center></pre></bdo></b><th id='A9lK9'></th></span></q></dt></tr></i><div id='A9lK9'><tfoot id='A9lK9'></tfoot><dl id='A9lK9'><fieldset id='A9lK9'></fieldset></dl></div>

  2. <tfoot id='A9lK9'></tfoot>
    <legend id='A9lK9'><style id='A9lK9'><dir id='A9lK9'><q id='A9lK9'></q></dir></style></legend>

    <small id='A9lK9'></small><noframes id='A9lK9'>

    • <bdo id='A9lK9'></bdo><ul id='A9lK9'></ul>

      如何以编程方式获取 DLL 或 EXE 文件的版本?

      时间:2023-08-02

      <small id='Ywn4z'></small><noframes id='Ywn4z'>

            <legend id='Ywn4z'><style id='Ywn4z'><dir id='Ywn4z'><q id='Ywn4z'></q></dir></style></legend>
            <i id='Ywn4z'><tr id='Ywn4z'><dt id='Ywn4z'><q id='Ywn4z'><span id='Ywn4z'><b id='Ywn4z'><form id='Ywn4z'><ins id='Ywn4z'></ins><ul id='Ywn4z'></ul><sub id='Ywn4z'></sub></form><legend id='Ywn4z'></legend><bdo id='Ywn4z'><pre id='Ywn4z'><center id='Ywn4z'></center></pre></bdo></b><th id='Ywn4z'></th></span></q></dt></tr></i><div id='Ywn4z'><tfoot id='Ywn4z'></tfoot><dl id='Ywn4z'><fieldset id='Ywn4z'></fieldset></dl></div>

              <tbody id='Ywn4z'></tbody>
            <tfoot id='Ywn4z'></tfoot>
              <bdo id='Ywn4z'></bdo><ul id='Ywn4z'></ul>

              • 本文介绍了如何以编程方式获取 DLL 或 EXE 文件的版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我需要使用 C 或 C++ 中的 Win32 本机 API 获取 DLL 或 EXE 文件的产品版本和文件版本.我要不是寻找 Windows 版本,而是通过右键单击 DLL 文件,选择属性",然后查看详细信息"选项卡所看到的版本号.这通常是一个由四部分组成的虚线版本号 x.x.x.x.

                I need to get the product version and file version for a DLL or EXE file using Win32 native APIs in C or C++. I'm not looking for the Windows version, but the version numbers that you see by right-clicking on a DLL file, selecting "Properties", then looking at the "Details" tab. This is usually a four-part dotted version number x.x.x.x.

                推荐答案

                您将使用 GetFileVersionInfo API.

                请参阅 MSDN 上的使用版本信息网站.

                See Using Version Information on the MSDN site.

                示例:

                DWORD  verHandle = 0;
                UINT   size      = 0;
                LPBYTE lpBuffer  = NULL;
                DWORD  verSize   = GetFileVersionInfoSize( szVersionFile, &verHandle);
                
                if (verSize != NULL)
                {
                    LPSTR verData = new char[verSize];
                
                    if (GetFileVersionInfo( szVersionFile, verHandle, verSize, verData))
                    {
                        if (VerQueryValue(verData,"\",(VOID FAR* FAR*)&lpBuffer,&size))
                        {
                            if (size)
                            {
                                VS_FIXEDFILEINFO *verInfo = (VS_FIXEDFILEINFO *)lpBuffer;
                                if (verInfo->dwSignature == 0xfeef04bd)
                                {
                
                                    // Doesn't matter if you are on 32 bit or 64 bit,
                                    // DWORD is always 32 bits, so first two revision numbers
                                    // come from dwFileVersionMS, last two come from dwFileVersionLS
                                    TRACE( "File Version: %d.%d.%d.%d
                ",
                                    ( verInfo->dwFileVersionMS >> 16 ) & 0xffff,
                                    ( verInfo->dwFileVersionMS >>  0 ) & 0xffff,
                                    ( verInfo->dwFileVersionLS >> 16 ) & 0xffff,
                                    ( verInfo->dwFileVersionLS >>  0 ) & 0xffff
                                    );
                                }
                            }
                        }
                    }
                    delete[] verData;
                }
                

                这篇关于如何以编程方式获取 DLL 或 EXE 文件的版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:如何在 C++ 中检测 win32 进程的创建/终止 下一篇:在本机 Windows 应用程序的资源中嵌入文本文件

                相关文章

                最新文章

                <small id='fVsKv'></small><noframes id='fVsKv'>

                <tfoot id='fVsKv'></tfoot>
                  <bdo id='fVsKv'></bdo><ul id='fVsKv'></ul>

                    <i id='fVsKv'><tr id='fVsKv'><dt id='fVsKv'><q id='fVsKv'><span id='fVsKv'><b id='fVsKv'><form id='fVsKv'><ins id='fVsKv'></ins><ul id='fVsKv'></ul><sub id='fVsKv'></sub></form><legend id='fVsKv'></legend><bdo id='fVsKv'><pre id='fVsKv'><center id='fVsKv'></center></pre></bdo></b><th id='fVsKv'></th></span></q></dt></tr></i><div id='fVsKv'><tfoot id='fVsKv'></tfoot><dl id='fVsKv'><fieldset id='fVsKv'></fieldset></dl></div>
                    <legend id='fVsKv'><style id='fVsKv'><dir id='fVsKv'><q id='fVsKv'></q></dir></style></legend>