码迷,mamicode.com
首页 > Windows程序 > 详细

delphi 读取编译的version信息

时间:2016-06-24 20:22:45      阅读:220      评论:0      收藏:0      [点我收藏+]

标签:

在create中调用就可以了

 

 

unit About;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, RzPanel, StdCtrls;

type
Tfrm_About = class(TForm)
RzPanel1: TRzPanel;
Image1: TImage;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
frm_About: Tfrm_About;

implementation

{$R *.dfm}

procedure Tfrm_About.FormCreate(Sender: TObject);
const
InfoNum = 9;
InfoStr: array[1..InfoNum] of string = (
‘ProductName‘,
‘ProductVersion‘,
‘FileDescription‘,
‘LegalCopyright‘,
‘FileVersion‘,
‘CompanyName‘,
‘LegalTradeMarks‘,
‘InternalName‘,
‘OriginalFileName‘
);
var
S: string;
BufSize, Len: DWORD;
Buf: PChar;
Value: PChar;
begin
S := Application.ExeName;
BufSize := GetFileVersionInfoSize(PChar(S), BufSize);
if BufSize > 0 then
begin

Buf := AllocMem(BufSize);
GetFileVersionInfo(PChar(S), 0, BufSize, Buf);
if VerQueryValue(Buf, PChar(‘StringFileInfo\080403A8\‘ + InfoStr[2]), Pointer(Value), Len) then
ShowMessage(Value);
if VerQueryValue(Buf, PChar(‘StringFileInfo\080403A8\‘ + InfoStr[1]), Pointer(Value), Len) then
ProductName.Caption := Value;
if VerQueryValue(Buf, PChar(‘StringFileInfo\080403A8\‘ + InfoStr[2]), Pointer(Value), Len) then
ProductVersion.Caption := ‘产品版本: ‘ + Value;
if VerQueryValue(Buf, PChar(‘StringFileInfo\080403A8\‘ + InfoStr[3]), Pointer(Value), Len) then
FileDescription.Caption := ‘文件说明: ‘ + Value;
if VerQueryValue(Buf, PChar(‘StringFileInfo\080403A8\‘ + InfoStr[4]), Pointer(Value), Len) then
LegalCopyright.Caption := ‘合法版权: ‘ + Value;
if VerQueryValue(Buf, PChar(‘StringFileInfo\080403A8\‘ + InfoStr[5]), Pointer(Value), Len) then
FileVersion.Caption := ‘文件版本: ‘ + Value;
if VerQueryValue(Buf, PChar(‘StringFileInfo\080403A8\‘ + InfoStr[6]), Pointer(Value), Len) then
CompanyName.Caption := ‘公司名称: ‘ + Value;
if VerQueryValue(Buf, PChar(‘StringFileInfo\080403A8\‘ + InfoStr[7]), Pointer(Value), Len) then
LegalTrademarks.Caption := ‘合法商标: ‘ + Value;
if VerQueryValue(Buf, PChar(‘StringFileInfo\080403A8\‘ + InfoStr[8]), Pointer(Value), Len) then
InternalName.Caption := ‘内部名称: ‘ + Value;
if VerQueryValue(Buf, PChar(‘StringFileInfo\080403A8\‘ + InfoStr[9]), Pointer(Value), Len) then
OriginalFilename.Caption := ‘原文件名: ‘ + Value;
FreeMem(Buf, BufSize);

// OperatingSystem.Caption := GetOSVerInfo;

// SystemMemory.Caption := GetMemStat;
end
else begin
Application.MessageBox(‘获取产品信息时遇到致命错误,请尝试重新启动软件。‘+ #13 + ‘若仍未能解决问题,请联系产品服务人员。‘,‘错误‘,MB_OK + MB_ICONSTOP);
Application.Terminate;
end;
end;

end.

delphi 读取编译的version信息

标签:

原文地址:http://www.cnblogs.com/zhangzhifeng/p/5615208.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!