Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi all, Is it possible to get th

Status
Not open for further replies.

TimSNL

Programmer
Sep 11, 2001
119
AU
Hi all,

Is it possible to get the date the application was compiled, from a variable at runtime.
I thought Delphi may have this tucked away in a system variable somewhere.

Tim
 
Create a console utility such as...

program programmer_stats;
uses crt, dos;
const quote : char = chr(39);
semi : char = ';';
var f : textfile;
begin
assignfile(f,'c:\progstat.inc');
rewrite(f);
writeln(f, ' const compile_date : string = ' + quote
+ formatdate('mm/dd/yyyy',date) + quote + semi);
closefile(f);
end.

Then put this utility in each of your development machines startup group so that it runs each morning when you start your machines.

Now all you have to do is include the resulting file
into your code using...

{$I c:\progstat.inc}
If it's stupid but it works, it isn't stupid
 
Check this out, it may help. I use this unit to find the version string for the application.

You may be able to play with it to find the exe date as well. I just grabbed it from somewhere so I didn't look any further than the version string.

Hope it can help:


unit Version;

// Returns version information from the VERSION_INFO resource

interface

procedure GetVersion(var MajorVersion, MinorVersion, Release, Build: integer);
function GetVersionFormatted: string;
function GetVersionFormattedNoBuild: string;

implementation
uses Windows, SysUtils;

type
RVersionInfo = record
achFiller: array [1..6] of char; // Unknown
VersionInfoHdr: array [1..16*2] of char; // WideString('VS_VERSION_INFO')
achFiller2: array[1..10] of char; // Unknown
MinorVersion: word;
MajorVersion: word;
Build: word;
Release: word;
end;
PVersionInfo = ^RVersionInfo;

procedure GetVersion(var MajorVersion, MinorVersion, Release, Build: integer);
var
Rsrc : HRSRC;
Res : HGLOBAL;
Version : PVersionInfo;
begin
MajorVersion := 0; MinorVersion := 0; Release := 0; Build := 0;
Rsrc := FindResource(HInstance, Pchar(1), RT_VERSION);
if Rsrc <> 0 then
begin
Res := LoadResource(HInstance, Rsrc);
Version := PVersionInfo(LockResource(Res));
MajorVersion := Version.MajorVersion;
MinorVersion := Version.MinorVersion;
Release := Version.Release;
Build := Version.Build;
end;
end;

function GetVersionFormatted: string;
var MajorVersion, MinorVersion, Release, Build: integer;
begin
GetVersion(MajorVersion, MinorVersion, Release, Build);
result := Format('%d.%d.%d:%d', [MajorVersion, MinorVersion, Release, Build]);
end;

function GetVersionFormattedNoBuild: string;
var MajorVersion, MinorVersion, Release, Build: integer;
begin
GetVersion(MajorVersion, MinorVersion, Release, Build);
result := Format('%d.%d.%d', [MajorVersion, MinorVersion, Release]);
end;

end.
 
There is a freeware component that does this, called 'Getver' I think, have a look on the component sites
Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top