Type   TFileVersionInfo   =   Record   
      FixedInfo:TVSFixedFileInfo;         {版本信息}   
      CompanyName:String;                         {公司名称}   
      FileDescription:String;                 {说明}   
      FileVersion:String;                         {文件版本}   
      InternalName:String;                       {内部名称}   
      LegalCopyright:String;                   {版权}   
      LegalTrademarks:String;                 {合法商标}   
      OriginalFilename:String;               {源文件名}   
      ProductName:String;                         {产品名称}   
      ProductVersion:String;                   {产品版本}   
      Comments:String;                               {备注}   
      LocalPort:String;                             {Local   UDP_Message   Port}   
  end;   
    
    
  Function   GetFileVerInfo(ExeFileName   :Pchar;var   VerSionInfo:TFileVersionInfo):Boolean;   
  var   
      dwHandle,   dwVersionSize       :   DWORD;   
      Find                                             :   String;   
      pcBuffer                                     :   PChar;   
      pTemp                                           :   Pointer;   
      FileVersionInfo                       :   TVSFixedFileInfo;   
  begin   
      Find   :=   '/';   
      dwVersionSize   :=   GetFileVersionInfoSize(   PChar(ExeFilename),dwHandle   );   
      if   dwVersionSize   =   0   then     begin   
          Result:=False;   
          Exit;   
      end;   
      GetMem(   pcBuffer,   dwVersionSize   );   
      if   not   GetFileVersionInfo(   PChar(ExeFilename),dwHandle,dwVersionSize,pcBuffer   )   then   begin   
          FreeMem(pcBuffer);   
          Result:=False;   
          Exit;   
      end;   
      if   not   VerQueryValue(   pcBuffer,PChar(Find),pTemp,dwVersionSize   )   then   begin   
          FreeMem(pcBuffer);   
          Result:=False;   
          Exit;   
      end;   
      FileVersionInfo:=PVSFixedFileInfo(pTemp)^;   
      With   FileVersionInfo   do   begin   
          VersionInfo.FixedInfo.dwSignature:=dwSignature;   
          VersionInfo.FixedInfo.dwStrucVersion:=dwStrucVersion;   
          VersionInfo.FixedInfo.dwFileVersionMS:=dwFileVersionMS;   
          VersionInfo.FixedInfo.dwFileVersionLS:=dwFileVersionLS;   
          VersionInfo.FixedInfo.dwProductVersionMS:=dwProductVersionMS;   
          VersionInfo.FixedInfo.dwProductVersionLS:=dwProductVersionLS;   
          VersionInfo.FixedInfo.dwFileFlagsMask:=FileVersionInfo.dwFileFlagsMask;   
          VersionInfo.FixedInfo.dwFileFlags:=fileVersionInfo.dwFileFlags;   
          VersionInfo.FixedInfo.dwFileOS:=FileVersionInfo.dwFileOS;   
          VersionInfo.FixedInfo.dwFileType:=FileVersionInfo.dwFileType;   
          VersionInfo.FixedInfo.dwFileSubtype:=FileVersionInfo.dwFileSubtype;   
          VersionInfo.FixedInfo.dwFileDateMS:=FileVersionInfo.dwFileDateMS;   
          VersionInfo.FixedInfo.dwFileDateLS:=FileVersionInfo.dwFileDateLS;   
      end;   
      Find   :=   '/StringFileInfo/080403A8/';   
      if   VerQueryValue(   pcBuffer,PChar(Find+'CompanyName'),pTemp,dwVersionSize   )   then   
          VersionInfo.CompanyName:=PChar(pTemp)   
      else   begin   
          Find   :=   '/StringFileInfo/040904E4/';   
          if   VerQueryValue(   pcBuffer,PChar(Find+'CompanyName'),pTemp,dwVersionSize   )   then   
              VersionInfo.CompanyName:=PChar(pTemp)   
          else   begin   
              Result:=False;   
              Exit;   
          end;   
      end;   
      if   VerQueryValue(   pcBuffer,PChar(Find+'FileDescription'),pTemp,dwVersionSize   )   then   
          VersionInfo.FileDescription:=PChar(pTemp);   
    
      if   VerQueryValue(   pcBuffer,PChar(Find+'FileVersion'),pTemp,dwVersionSize   )   then   
          VersionInfo.FileVersion:=PChar(pTemp);   
    
      if   VerQueryValue(   pcBuffer,PChar(Find+'InternalName'),pTemp,dwVersionSize   )   then   
          VersionInfo.InternalName:=PChar(pTemp);   
    
      if   VerQueryValue(   pcBuffer,PChar(Find+'LegalCopyright'),pTemp,dwVersionSize   )   then   
          VersionInfo.LegalCopyright:=PChar(pTemp);   
    
      if   VerQueryValue(   pcBuffer,PChar(Find+'LegalTrademarks'),pTemp,dwVersionSize   )   then   
          VersionInfo.LegalTrademarks:=PChar(pTemp);   
    
      if   VerQueryValue(   pcBuffer,PChar(Find+'OriginalFilename'),pTemp,dwVersionSize   )   then   
          VersionInfo.OriginalFilename:=PChar(pTemp);   
    
      if   VerQueryValue(   pcBuffer,PChar(Find+'ProductName'),pTemp,dwVersionSize   )   then   
          VersionInfo.ProductName:=PChar(pTemp);   
    
      if   VerQueryValue(   pcBuffer,PChar(Find+'ProductVersion'),pTemp,dwVersionSize   )   then   
          VersionInfo.ProductVersion:=PChar(pTemp);   
    
      if   VerQueryValue(   pcBuffer,PChar(Find+'Comments'),pTemp,dwVersionSize   )   then   
          VersionInfo.Comments:=PChar(pTemp);   
      if   VerQueryValue(   pcBuffer,PChar(Find+'LocalPort'),pTemp,dwVersionSize   )   then   
          VersionInfo.LocalPort:=PChar(pTemp)   
      else   
          VersionInfo.LocalPort:='66500';   
      FreeMem(pcBuffer   );   
      Result:=True;   
  end;

http://blog.csdn.net/henreash/article/details/2246774

获取Exe文件版本信息的函数(使用GetFileVersionInfo得到TFileVersionInfo结构体,包含12项内容)的更多相关文章

  1. mfc获取exe的版本信息

    CString GetFileVersion(const CString& sTargetFileName){ DWORD nInfoSize = 0, dwHandle = 0; nInfo ...

  2. Python获取exe文件版本

    import time, datetime, re, subprocess, sys, os, win32net, win32api, win32con, win32netcon, win32secu ...

  3. 获取 Android APP 版本信息工具类(转载)

    获取 Android APP 版本信息工具类 获取手机APP版本信息工具类 1.获取版本名称 2.获取版本号 3.获取App的名称 package com.mingyue.nanshuibeidiao ...

  4. Powershell 获取文件版本信息

    获取文件版本信息,通过FileVersionInfo::GetVersioninfo(file) 来获取信息 function Check-DdpstoreFileVersion{ $Ddpstore ...

  5. LevelDB源码之五Current文件\Manifest文件\版本信息

    版本信息有什么用?先来简要说明三个类的具体用途: Version:代表了某一时刻的数据库版本信息,版本信息的主要内容是当前各个Level的SSTable数据文件列表. VersionSet:维护了一份 ...

  6. E1.获取Elixir/Erlang版本信息

    E1.获取Elixir/Erlang版本信息 获取Elixir版本 直接在shel中打开iex (interactive shell),就可以查到具体的版本信息: iex Erlang/OTP 22 ...

  7. 实现php获取mp3文件元信息如播放时间歌曲作者等

    最近收集到一个php获取mp3文件元信息的类,感觉比较方便.现在分享给大家! 下面是使用方式和测试方式: <?php include_once 'mp3file.class.php'; func ...

  8. [转]SVN使用log,list,cat,diff查看所有及特定文件版本信息

    [转]SVN使用log,list,cat,diff查看所有及特定文件版本信息 http://onefishum.blog.163.com/blog/static/5184730520113153402 ...

  9. linux 系统获得当前文件夹下存在的所有文件 scandir函数和struct dirent **namelist结构体[转]

    linux 系统获得当前文件夹下存在的所有文件 scandir函数和struct dirent **namelist结构体 1.引用头文件#include<dirent.h> struct ...

随机推荐

  1. pomelo研究笔记-RPCclient

    1. mailbox数据收发模块 一个RPC客户端可能同一时候须要调用多个远端(server)提供的服务.在pomelo里每一个server抽象为一个mailbox.先来看看mailbox的实现: v ...

  2. android 逆向project smail 语法学习

    众所周知,android 是开源的.如今市场上反编译别人的劳动果实的人也不少.所以我们也是有必要学习下smail语言,(就是androidproject反编译后出的语法语音),看看改怎么给我们的代码 ...

  3. HTTP协议--状态码

    HTTP状态码负责表示客户端HTTP请求返回的结果.标记服务器端的处理是否正常.通知出现的错误等工作. 常用状态码共分5大类: 1XX:Informational,信息性状态码,接收的请求正在处理. ...

  4. 在VS中实现webService的一个demo(图解)

    在VS中实现webService的一个demo(图解) 先创建一个web项目,创建好web项目后,添加新建项——web服务 在新建好的web服务文件中写如下代码: 生成当前解决方案. 新建一个winf ...

  5. 基于visual Studio2013解决面试题之1408桶排序

     题目

  6. (step 8.2.8)hdu 1079(Calendar Game)

    题目大意是: 两个家伙在区域赛前夕闲的无聊,然后玩一种无限纠结的游戏,随即给定一个日期,每次只能移动day OR month.......... 而且如果下一个月没有当前day的话, 你就不能移动mo ...

  7. JS Call()与Apply()

    JS Call()与Apply() ECMAScript规范给所有函数都定义了Call()与apply()两个方法,call与apply的第一个参数都是需要调用的函数对象,在函数体内这个参数就是thi ...

  8. mmc生产运输投资问题

    本题目,有生产,运输和投资,由于能力不能满足需求, 要扩大生产规模.

  9. 禁止页面复制功能 js禁止复制 禁用页面右键菜单

    <body oncontextmenu="return false">禁用网页右键菜单,但是仍然可以使用快捷键复制. js代码禁用复制功能: <script  t ...

  10. Cocos2d-x教程(30)-3.x版本号物理引擎的使用

    转载时请注明原文出处 : http://blog.csdn.net/u012945598/article/details/38417333 在Cocos2d-x 2.x的版本号中,开发人员能够直接使用 ...