I'd like to be able to display in a Delphi 2009 program, the date and time that the program was compiled.
Is there a simple way to do this?
I'd like to be able to display in a Delphi 2009 program, the date and time that the program was compiled.
Is there a simple way to do this?
An obvious choice could be to use the last modified date for the exe, but this can be changed.
You could include the compile timestamp in the version information and read that resource. I seem to remember an IDE add-in that does this for you, but not which one.
Or you could read the timestamp from the PE header.
A friend of mine, Michael Puff, has provided a solution to read the compiliation time from an Delphi application. It is posted here: http://www.michael-puff.de/Developer/Delphi/Code-Snippets/GetImageLinkTimeStamp.shtml
I also use the PE header timestamp. The problem with it was (at least with older versions) that Delphi did not update it correctly. I'm not sure if this has been fixed in Delphi 2010. I've written an IDE plugin to update the PE header automatically after each compile. You can get it from CodeCentral: 19823 Update PE header TimeDateStamp value after compilation.
At least since Delphi 2007 the linker timestamp in the PE Header should be written. (In older versions like Delphi 5 the timestamp in the PE header was something in 1992 and the real timestamp could only be found in the resources)
If you already use the JCL then try PeReadLinkerTimeStamp from JclPEImage.pas SVN View
I use a simple IDE add-in which I wrote to walk all the source files in the project and write a .INC file containing the latest of the modification times. This is done automatically as a 'before compile' action. I find it more useful than a simple 'last compile' date because it reflects more accurately the last time the project was changed. And since all projects in our applications get compiled in FinalBuilder for each build, a 'last compile' time would result in a bunch of similar timestamps, signifying not much of interest. The only disadvantage is that this mechanism does not record changes to our library of utiltity functions which are not part of any project; but they do not change very often. If you really need just the compile date, however, a similar IDE add-in could do this instead.