zoukankan      html  css  js  c++  java
  • 获取File Version 和Product Version

    #include <stdio.h>
    #include <windows.h>

    #ifndef nullptr
     #define nullptr NULL
    #endif

    int _tmain(int argc, _TCHAR* argv[])
    {
        if (argc > 1)
        {
            DWORD dwSize = GetFileVersionInfoSize(argv[1], nullptr);
            if (dwSize > 0)
            {
                BYTE* pBlock = (BYTE*)malloc(dwSize);
                if (pBlock != nullptr)
                {
                    if (GetFileVersionInfo(argv[1], 0, dwSize, pBlock))
                    {
                        VS_FIXEDFILEINFO* pFixedFileInfo = nullptr;
                        UINT uSize = 0;
                        if (VerQueryValue(pBlock, _T("\"), (void**)&pFixedFileInfo, &uSize) &&
                            (uSize == sizeof(VS_FIXEDFILEINFO)))
                        {
                            printf("File Version: %d.%d.%d.%d ",
                                         pFixedFileInfo->dwFileVersionMS >> 16,
                                         pFixedFileInfo->dwFileVersionMS & 0xFFFF,
                                         pFixedFileInfo->dwFileVersionLS >> 16,
                                         pFixedFileInfo->dwFileVersionLS & 0xFFFF);

                            printf("Product Version: %d.%d.%d.%d ",
                                         pFixedFileInfo->dwProductVersionMS >> 16,
                                         pFixedFileInfo->dwProductVersionMS & 0xFFFF,
                                         pFixedFileInfo->dwProductVersionLS >> 16,
                                         pFixedFileInfo->dwProductVersionLS & 0xFFFF);
                        }
                    }
                    free(pBlock);
                    pBlock = 0;
                }
            }
        }

        return 0;
    }

  • 相关阅读:
    openstack 杂记 备忘
    centos7 开机/etc/rc.local 不执行的问题
    Rabbit-service Message queue MQ 验证 校验
    MySQL max_connections 总是 214 。不能设大了? max_connections = 214
    Mariadb-lib
    SQL service 自动解决依赖包 验证
    SQL service
    createrepo
    mkisofs
    【Linux探索之旅】第四部分第三课:文件传输,潇洒同步
  • 原文地址:https://www.cnblogs.com/yilang/p/12524333.html
Copyright © 2011-2022 走看看