unit uAbout;

interface

uses
  Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
  Buttons, ExtCtrls, pngimage, AbGradient, Dialogs,   ImageHlp, PJVersionInfo,
  _GClass ;

type
  TfrmAbout = class(TForm)
    pnlAbout: TPanel;
    gradient: TAbGradient;
    moInfo: TMemo;
    OKButton: TButton;
    lblComments: TLabel;
    lblVersion: TLabel;
    lblProductName: TLabel;
    ProgramIcon: TImage;
    lblCompanyName: TLabel;
    lblJamesBrown: TLabel;
    PJVersionInfo: TPJVersionInfo;
    procedure OKButtonClick(Sender: TObject);
    procedure btnTestClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }

  public
    { Public declarations }
    Function ShowVersion: String; // (AppName: String); // File with version Information..
    Function getFileVersion: String;
     function LinkerTimeStamp(const FileName: string): TDateTime; overload;
  end;

var
  frmAbout: TfrmAbout;

implementation

{$R *.dfm}

procedure TfrmAbout.OKButtonClick(Sender: TObject);
begin
  close;

end;

function TfrmAbout.LinkerTimeStamp(const FileName: string): TDateTime ;
var
  LI: TLoadedImage;
begin

// Win32Check(MapAndLoad(PChar(FileName), nil, @LI, False, True));
  Win32Check(MapAndLoad('D:\SETINet\about\AboutTest\Win32\Debug\AboutTest.exe'  , nil, @LI, False, True)) ;
  Result := LI.FileHeader.FileHeader.TimeDateStamp / SecsPerDay + UnixDateDelta;
  UnMapAndLoad(@LI);
end;

// Procedure TAboutBox.ApplicationName(AppName: string);
Function TfrmAbout.ShowVersion: String;
begin
  PJVersionInfo.FileName := ExtractFileName(Application.ExeName);
  // get name of whatever app is calling
  With moInfo do
  begin
    moInfo.Lines.BeginUpdate;
    Lines.Clear;

    With PJVersionInfo do
    begin
      lblComments.Caption := Comments;

      if CompanyName <> '' then
      begin
        Lines.Add('Company: ' + CompanyName);
        lblCompanyName.Caption := CompanyName;
      end;

      if FileDescription <> '' then
        Lines.Add('FileDescription: ' + FileDescription);
      if FileVersion <> '' then
      begin
        Lines.Add('FileVersion: ' + FileVersion);
        lblVersion.Caption := 'FileVersion: ' + FileVersion;
      end;

      if InternalName <> '' then
        Lines.Add('InternalName: ' + InternalName);
      if LegalCopyright <> '' then
        Lines.Add('Copyright: ' + LegalCopyright);
      if LegalTrademarks <> '' then
        Lines.Add('Trademarks: ' + LegalTrademarks);
      if OriginalFilename <> '' then
        Lines.Add('OriginalFileName: ' + OriginalFilename);

      if ProductName <> '' then
      begin
        lblProductName.Caption := ProductName;
        Lines.Add('ProductName: ' + ProductName);
      end;

      if PJVersionInfo.ProductVersion <> '' then
        Lines.Add('ProductVersion: ' + ProductVersion);

      if Comments <> '' then
        Lines.Add('Comments: ' + Comments);

      moInfo.Height := ((Abs(moInfo.Font.Height)) * (moInfo.Lines.Count)) * 2;
       Height := 20 + moInfo.Height + ((Abs(moInfo.Font.Height) * moInfo.Lines.Count) * 2);
      Lines.EndUpdate;
    end;
  end;
  Visible := True;

  Result := PJVersionInfo.FileVersion;
end;

procedure TfrmAbout.btnTestClick(Sender: TObject);
begin
  ShowVersion;
end;

procedure TfrmAbout.FormCreate(Sender: TObject);
begin
{$IFDEF EUREKALOG}
   Caption :=  Caption + (' + EurekaLog ');
{$ENDIF}
   Caption :=  Caption + ' (' + IntToStr(SizeOf(Pointer) * 8) + ' Bit)';
end;

Function TfrmAbout.getFileVersion: String;
begin
  Result := PJVersionInfo.FileVersion;

end;

end.
