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. Android--pendingIntent & Intent

    PendingIntent pendingIntent字面意义:等待的,未决定的Intent.要得到一个pendingIntent对象,使用方法类的静态方法 getActivity(Context, ...

  2. Android Activity 常用功能设置(全屏、横竖屏等)

    Activity全屏设置 方式1:AndroidManifest.xml <activity android:name="myAcitivty"  android:theme ...

  3. cmake总结

    无论生活还是工作上,做过的事,需要总结下. 接触cmake,一般都会看一本书 <<cmake 实践>>. 这是cmake的入门书.我就不多说了. 下面说一下我对部分cmake命 ...

  4. shapefile 编码错误问题解决 Wrong codepage of shapefile Warning 1: One or several characters couldn't be converted correctly from UTF-8 to ISO-8859-1.

    linux下运行,因为大部分shapefile 文件,在使用时都没有指定字符集,所以qgis只能从环境变量中获取设置环境变量中获取SHAPE_ENCODING. 目前唯一的解决办法就是设置环境变量 $ ...

  5. 创建用于编译和运行Java程序的批处理文件

    创建用于编译和运行Java程序的批处理文件 每次编译或运行Java程序时,都要在DOS命令行中输入很长的javac或java命令,悟空觉得太麻烦,就编写了一个适用于Windows操作系统的批处理文件b ...

  6. POJ 1700 cross river (数学模拟)

                                                                                                       ...

  7. ICMP:Internet控制报文协议

    ICMP:Internet控制报文协议. 是IP层的组成部分.传递差错报文或其他信息. ICMP报文被封装在IP数据报内部: 详细格式例如以下所看到的: 个字段含义例如以下: 8位类型. 表示该ICM ...

  8. 1030 - Image Is Everything

    Your new company is building a robot that can hold small lightweight objects. The robot will have th ...

  9. Swift - 使用CABasicAnimation实现动画效果

    1,CABasicAnimation类只有三个属性: fromValue:开始值 toValue:结束值 Duration:动画的时间 2,通过animationWithKeyPath键值对的方式设置 ...

  10. 浅析js的执行顺序

    javascript是一种描述型的脚本语言,是一种解析语言,由浏览器动态解析,不同种类的浏览器不同版本的浏览器对于js的解析有着微小的差别,不同浏览器的js解析引擎效率也有高低,下面来给大家分析一下j ...