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. [转]SELinux管理与配置

    原文链接:http://blog.csdn.net/huangbiao86/article/details/6641893 1.1 SElinux概述 SELinux(Security-Enhance ...

  2. 深入windows的关机消息截获-从XP到Win7的变化

    之前写了一个软件用于实验室的打卡提醒,其中一个重要的功能是在关机之前提醒当天晚上是否已经打卡.之前我是在WM_ENDSESSION中弹出一个模态对话框来提醒,在XP中基本工作正常,在Win7中大多数时 ...

  3. 线程:Message和Runnable

    原文地址http://blog.csdn.net/flowingflying/article/details/6370184 程序需要相应用户的操作,最要能在200ms(0.2s)之内,如果超过5秒没 ...

  4. intent.getAction()

    这个是发送端注册上的IntentFilter filter = new IntentFilter( Intent.ACTION_MEDIA_SCANNER_STARTED); filter.addAc ...

  5. mysql禁用autocommit,以及遇到的问题(转)

    MySQL的autocommit(自动提交)默认是开启,其对mysql的性能有一定影响,举个例子来说,如果你插入了1000条数据,mysql会commit1000次的,如果我们把autocommit关 ...

  6. vi 快捷键积累

    依据自己用到的.或者还没记住的.或者用的时候忘了的,慢慢积累. 一.全选复制粘贴. 全选: ggVG // 凝视: gg 光标移到首行 V 进入Visual(可视)模式 G 光标移到最后一行全选 选中 ...

  7. 饭卡(HDOJ2546)

    饭卡 Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submiss ...

  8. itextSharp 对pdf的每个页面添加footer/header

    static void SetAllHeaderFooter(string inputPath) { PdfReader reader=new PdfReader(inputPath); PdfSta ...

  9. ASP.NET - (Session)后台登陆时,判断是不是已经登陆,如果不是,跳转回登陆页

    admin(小写):用户输入的账户. password(小写):用户输入的密码. 1.先将用户名和密码,存储到Session会话中. Session["Admin"] = admi ...

  10. Qt exe图标

    1.首先准备一张ico照片,也可以通过http://www.ico.la/生成: 2.把ico照片拷贝到项目工程下,比如:“pic.ico” 3.在工程下,创建一个文件“myapp.rc”,用txt打 ...