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对象

    package file; import java.io.File; public class FileTest1 { public static void main(String[] args) { ...

  2. 一些Xcode 5的使用提示和技巧

    摘自:http://www.cocoachina.com/newbie/env/2014/0127/7766.html 感谢论坛成员郭亚鑫的热心翻译.   在iOS开发中,Xcode 是最使用最多的I ...

  3. 02-UIKit控件、MVC

    目录: 一.控件使用 二.动态类型和静态类型 三.MVC 四.UIAlertView对话框 回到顶部 一.控件使用 1 事件源,事件处理方法有一个参数传进来,那个参数就是触发这个事件的时间源. UIS ...

  4. KestrelServer

    KestrelServer 跨平台是ASP.NET Core一个显著的特性,而KestrelServer是目前微软推出了唯一一个能够真正跨平台的Server.KestrelServer利用一个名为Ke ...

  5. 高斯拉普拉斯算子(Laplace of Gaussian)

    高斯拉普拉斯(Laplace of Gaussian) kezunhai@gmail.com http://blog.csdn.net/kezunhai Laplace算子作为一种优秀的边缘检测算子, ...

  6. ios qq 分享 失败

    1. TencentOAuth 是需要调用,但QQ代码共享是没有解释.共享代码如下面: TencentOAuth *auth = [[TencentOAuth alloc] initWithAppId ...

  7. UML看书笔记1:主体思想

    对象设计需要解决的三大问题:      1.把“现实世界”映射到“对象世界”      2.从“对象世界”描述“现实世界”      3.验证“对象世界”是否反映了“现实世界” 现实世界与我们的对象世 ...

  8. Android SurfaceView实战 打造抽奖转盘

    转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/41722441 ,本文出自:[张鸿洋的博客] 1.概述 今天给大家带来Surfac ...

  9. var, object, dynamic的区别以及使用(转载)

    var, object, dynamic的区别以及使用 阅读目录: 一. 为什么是它们三个 二. 能够任意赋值的原因 三. dynamic的用法 四. 使用dynamic的注意事项 拿这三者比较的原因 ...

  10. java调用C#的dll

    链接地址:http://www.cnblogs.com/yinhaiming/articles/1712463.html .net产生的比java晚,其类库的封装在某些方面也比java更优秀,更全面. ...