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. File 操纵目录

    mkdir()   创建目录 不可及联创建    即父路径中一旦有不存在文件夹  即创建失败 mkdirs() 创建目录,及联创建 list() 列出目录内所包含的文件名(string) listFi ...

  2. Windows Azure 网站的 IP 和域限制

    编辑人员注释:本文章由 Windows Azure 网站团队的首席项目经理 Stefan Schackow 撰写. 配置 Azure 网站 (WAWS) 的 IP 和域限制一直是用户最迫切希望我们提供 ...

  3. 圣魔大战3(Castle Fantisia)艾伦希亚战记完美攻略

    作为城堡幻想曲系列续作,艾伦希亚战记继承了前作的战棋+养成模式进行游戏. (城堡幻想曲3,纠正大家个错误哦,不是圣魔大战3,圣魔大战是城堡幻想曲2,圣魔大战不是个系列,艾伦西亚战记==艾伦希亚战记,一 ...

  4. ADO.NET 对象 结构图

  5. SQL 教程

    SQL 教程 http://www.w3school.com.cn/sql/

  6. 分布式消息系统jafka快速起步(转)

    Jafka 是一个开源的/性能良好的分布式消息系统.在上一篇文章中有所简单介绍.下面是一篇简单的入门文档.更多详细的文档参考wiki. Step 1: 下载最新的安装包 完整的安装指南在这里.最新的发 ...

  7. Why Python?

    Python is object-oriented Structure supports such concepts as polymorphism , operation overloading , ...

  8. [整理]MongoDB 经常使用命令总结

    MongoDB 经常使用命令总结 简单的的增删改查数据 在查询结果中指定显示或者不显示某个字段 比如,我们希望在 lessons 集合中查找全部数据,可是不希望在返回结果中包括 slides 字段:由 ...

  9. <转载>网页设计中的F式布局

    地址:http://www.uisdc.com/understanding-the-f-layout-in-web-design 网页设计中的F式布局 今天我们来重点介绍网页设计中的F式布局.传统的布 ...

  10. android的单元测试

    1.新建android Test project 2. 选择针对测试的项目 3.新建类继承AndroidTestCase即可: package com.howlaa.sms.test; import ...