Отобразить информацию из Version Info проекта
Автор: Xavier Pacheco
{
Copyright © 1999 by Delphi 5 Developer's Guide - Xavier Pacheco and Steve Teixeira
}
unit MainFrm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls,
Forms, Dialogs, FileCtrl, StdCtrls, verinfo, Grids, Outline, DirOutln,
ComCtrls;
type
TMainForm = class(TForm)
lvVersionInfo: TListView;
btnClose: TButton;
procedure FormDestroy(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure btnCloseClick(Sender: TObject);
private
VerInfoRes: TVerInfoRes;
end;
var
MainForm: TMainForm;
implementation
{$R *.DFM}
procedure AddListViewItem(const aCaption, aValue: string; aData: Pointer;
aLV: TListView);
// This method is used to add a TListItem to the TListView, aLV
var
NewItem: TListItem;
begin
NewItem := aLV.Items.Add;
NewItem.Caption := aCaption;
NewItem.Data := aData;
NewItem.SubItems.Add(aValue);
end;
procedure TMainForm.FormCreate(Sender: TObject);
begin
VerInfoRes := TVerInfoRes.Create(Application.ExeName);
end;
procedure TMainForm.FormDestroy(Sender: TObject);
begin
VerInfoRes.Free;
end;
procedure TMainForm.FormShow(Sender: TObject);
var
VerString: string;
i: integer;
sFFlags: string;
begin
for i := ord(viCompanyName) to ord(viComments) do
begin
VerString := VerInfoRes.GetPreDefKeyString(TVerInfoType(i));
if VerString <> '' then
AddListViewItem(VerNameArray[TVerInfoType(i)], VerString, nil,
lvVersionInfo);
end;
VerString := VerInfoRes.GetUserDefKeyString('Author');
if VerString <> EmptyStr then
AddListViewItem('Author', VerString, nil, lvVersionInfo);
AddListViewItem('File Version', VerInfoRes.FileVersion, nil,
lvVersionInfo);
AddListViewItem('Product Version', VerInfoRes.ProductVersion, nil,
lvVersionInfo);
for i := 0 to VerInfoRes.FileFlags.Count - 1 do
begin
if i <> 0 then
sFFlags := SFFlags + ', ';
sFFlags := SFFlags + VerInfoRes.FileFlags[i];
end;
AddListViewItem('File Flags', SFFlags, nil, lvVersionInfo);
AddListViewItem('Operating System', VerINfoRes.FileOS, nil, lvVersionInfo);
end;
procedure TMainForm.btnCloseClick(Sender: TObject);
begin
Close;
end;
end.
|