标签:
在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.
标签:
原文地址:http://www.cnblogs.com/zhangzhifeng/p/5615208.html