DelphiFAQ Home Search:

How to get the compile Date into the executable

 

comments4 comments. Current rating: 2 stars (1 votes). Leave comments and/ or rate it.

It's very nice to have a number say in the about box that the customer can read you, and you can immediately find the version.

Write a program which outputs the current date to a text file called something like 'today.inc' and include it with {$include today.inc} in each of your units.
Then integrate this little tool into your Delphi IDE and run it every time you make a new build.

// by Martin Larsson, martin.larsson@delfi-data.msmail.telemax.no
// include file "today.inc"
const
   _day   : string[10] = 'Monday';
   _date  : word = 12;
   _month : word = 8;
   _year  : word = 1996;

Comments:

2007-01-29, 19:38:08
anonymous from Korea (R)  
'Then integrate this little tool into your Delphi IDE and run it every time you make a new build.'

Running that little tool manually isn't a matter. But is there a way to run it automatically before building?
2008-02-06, 19:07:40
anonymous from Hong Kong  
rating
well, I don't see any post or pre build events in my Delphi 7 contrary to VS2005. Am I missing something or this is just wishfull thinking.
2008-03-20, 16:01:04
ksi@telkomsa.net from South Africa  
An easier and neater way is to use the compiled project exe file date. In VB .NET 2003 this is easily done with

Inports System.IO
,
,
,

dim strDate as string
dim fName as string

fName = Application.StartupPath & '\YourProjectFilename.exe'

strDate= File.GetLastWriteTime(fName)

QED
2008-04-17, 19:44:12
periander@hotmail.com from Australia  
I would not suggest using the last write time if you are depending on the version for things such as database restructuring, (i.e., if you're using version 20080401 but the exe says it's version 20080418). The reason for this is that your executable's 'Date Modified' can be altered fairly easily, and as such does not represent the actual compilation date always.

That being said, it will work most of the time, and it is a fairly neat way.

The first suggestion is probably better, basically having a const hard coded to a date and/or time stamp.

 

 

Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option.
 
It seems that you are
from Washington, US .

Info/ Feedback on this

Show city and country
Show country only
Hide my location
Leave your comment here:
Please type in the code:
photo Add a picture:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity. The owner of this web site reserves the right to delete such material.