获取Exe文件版本信息的函数(使用GetFileVersionInfo得到TFileVersionInfo结构体,包含12项内容)
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项内容)的更多相关文章
- mfc获取exe的版本信息
CString GetFileVersion(const CString& sTargetFileName){ DWORD nInfoSize = 0, dwHandle = 0; nInfo ...
- Python获取exe文件版本
import time, datetime, re, subprocess, sys, os, win32net, win32api, win32con, win32netcon, win32secu ...
- 获取 Android APP 版本信息工具类(转载)
获取 Android APP 版本信息工具类 获取手机APP版本信息工具类 1.获取版本名称 2.获取版本号 3.获取App的名称 package com.mingyue.nanshuibeidiao ...
- Powershell 获取文件版本信息
获取文件版本信息,通过FileVersionInfo::GetVersioninfo(file) 来获取信息 function Check-DdpstoreFileVersion{ $Ddpstore ...
- LevelDB源码之五Current文件\Manifest文件\版本信息
版本信息有什么用?先来简要说明三个类的具体用途: Version:代表了某一时刻的数据库版本信息,版本信息的主要内容是当前各个Level的SSTable数据文件列表. VersionSet:维护了一份 ...
- E1.获取Elixir/Erlang版本信息
E1.获取Elixir/Erlang版本信息 获取Elixir版本 直接在shel中打开iex (interactive shell),就可以查到具体的版本信息: iex Erlang/OTP 22 ...
- 实现php获取mp3文件元信息如播放时间歌曲作者等
最近收集到一个php获取mp3文件元信息的类,感觉比较方便.现在分享给大家! 下面是使用方式和测试方式: <?php include_once 'mp3file.class.php'; func ...
- [转]SVN使用log,list,cat,diff查看所有及特定文件版本信息
[转]SVN使用log,list,cat,diff查看所有及特定文件版本信息 http://onefishum.blog.163.com/blog/static/5184730520113153402 ...
- linux 系统获得当前文件夹下存在的所有文件 scandir函数和struct dirent **namelist结构体[转]
linux 系统获得当前文件夹下存在的所有文件 scandir函数和struct dirent **namelist结构体 1.引用头文件#include<dirent.h> struct ...
随机推荐
- C语言顺序栈实现
/*数序栈*/ #include<stdio.h> #include<stdlib.h> #include<math.h> #define SElemType ch ...
- android代码控制seekbar的样式
package com.zte; import android.app.Activity; import android.graphics.Color; import android.graphics ...
- Java 生成本文文件的时候,Dos格式转成Unix格式
仅仅须要在生成文本的最后 加上 sb.append("\n\r");就可以 是/n/r 不是/r/n
- asp.net导出Excel类库
using System; using System.Collections.Generic; using System.Reflection; using System.Web; using Exc ...
- 第1章 软件测试基本概念(Week1,3月3日)
一.对软件的认识 1. 什么是软件 2. 软件的分类 3. 软件开发的生命周期模型 (1)瀑布模型 (2)Scrum 其实对用瀑布模型这种臃肿不堪.要求严格.而无法适应软件开发周期变化的开发模型,渐渐 ...
- Windows下用WinSCP传输数据到Linux上
Scenario:最近公司做的一个项目,UI部分我是使用python在编译时做localization的,是linux下运行的,但是开发是在windows下进行的每次编译后都要手动通过WinSCP这个 ...
- WCF技术剖析之十七:消息(Message)详解(中篇)
原文:WCF技术剖析之十七:消息(Message)详解(中篇) [爱心链接:拯救一个25岁身患急性白血病的女孩[内有苏州电视台经济频道<天天山海经>为此录制的节目视频(苏州话)]]在上篇中 ...
- Android 解屏幕锁与点亮屏幕
前言 欢迎大家我分享和推荐好用的代码段~~ 声明 欢迎转载,但请保留文章原始出处: CSDN:http://www.csdn.net ...
- 基于visual Studio2013解决面试题之1002公共子串
题目
- Hadoop学习之HBase
1. HBase有哪些基本的特征? 2. HBase相对于关系数据库能解决的问题是什么? 3. HBase的数据模型是什么?如何表述?有哪些操作形式? 4. HBase的模式Schema设计的一些概念 ...