unit Unit2;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.StdCtrls, ShellAPI;
type
TVersionInfo =
packed record
Major : DWORD;
Minor : DWORD;
Release: DWORD;
Build : DWORD;
end;
type
TForm2 =
class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
function GetFileVersion(
const FileName: PWideChar): TVersionInfo;
var
VerInfoSize : Integer;
VerValueSize: DWord;
Dummy : DWord;
VerInfo : Pointer;
VerValue : PVSFixedFileInfo;
begin
VerInfoSize := GetFileVersionInfoSize(Filename,Dummy);
If VerInfoSize <> 0
then
begin
GetMem(VerInfo, VerInfoSize);
try
If GetFileVersionInfo(Filename, 0, VerInfoSize,VerInfo)
then
If VerQueryValue(VerInfo, '
\', Pointer(VerValue), VerValueSize)
then
begin
Result.Major := VerValue^.dwFileVersionMS
shr 16;
Result.Minor := VerValue^.dwFileVersionMS
and $FFFF;
Result.Release := VerValue^.dwFileVersionLS
shr 16;
Result.Build := VerValue^.dwFileVersionLS
and $FFFF;
end;
finally
FreeMem(VerInfo, VerInfoSize);
end;
end;
end;
procedure TForm2.Button1Click(Sender: TObject);
var
S :
String;
VersionInfo: TVersionInfo;
begin
VersionInfo := GetFileVersion(PWideChar(Application.ExeName));
S := Format('
Copyright by me!' + #13 + '
Version: %d.%d.%d.%d',
[VersionInfo.Major, VersionInfo.Minor, VersionInfo.Release, VersionInfo.Build]);
ShellAbout(self.Handle, PWideChar(Text), PWideChar(S), Application.Icon.Handle);
end;
end.