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;
    }

  • 相关阅读:
    剑指offer51-正则表达式匹配
    剑指offer50-构建乘积数组
    剑指offer49-数组中的重复
    PHP系列笔记——Zend_Controller工作流程
    多态与重载
    读取文件数据的大概流程
    基于HTTP协议下载文件的实现
    C++中的面向对象笔记
    firebreath注册接口
    python读取excelxlsx,写入excel
  • 原文地址:https://www.cnblogs.com/yilang/p/12524333.html
Copyright © 2011-2022 走看看