delphi 读取编译的version信息
在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.
最新文章
- Spring Boot -- 启动彩蛋
- Java正则表达式, 提取双引号中间的部分
- CentOS 安装ftp
- dnf脚本的研究
- ibeacons社区
- 九度OJ 1131 合唱队形 -- 动态规划(最长递增子序列)
- APP安全环节缺失,手游运营商怎样应对APP破解困境
- target-action传值
- 模式识别 - libsvm该函数的调用方法 详细说明
- SSH没有password安全日志
- shell 多进程
- TxDragon的训练5
- strman--java8字符串工具类
- 详解IPTABLES
- [python] PyMouse、PyKeyboard用python操作鼠标和键盘
- maven项目(多模块)
- Android相关 博客收藏
- TCP/IP学习20180701-数据链路层-IP子网寻址
- 《机器学习实战》之k-近邻算法(示例)
- Python day21模块介绍4(logging模块,configparser模块)