English 中文(简体)
How Can I Get the Compile Date and Time in Delphi
原标题:

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?

问题回答

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

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.

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.

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.





相关问题
determining the character set to use

my delphi 2009 app has a basic translation system that uses GNUGetText. i had used some win API calls to prepare the fonts. i thought it was working correctly until recently when someone from Malta ...

Help with strange Delphi 5 IDE problems

Ok, I m going nuts here. For the last (almost) four years, I ve been putting up with some extremely bad behavior from my Delphi 5 IDE. Problems include: Seemingly random errors in coride50.bpl ...

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How convert string to integer in Oxygene

In Delphi, there is a function StrToInt() that converts a string to an integer value; there is also IntToStr(), which does the reverse. These functions doesn t appear to be part of Oxygene, and I can ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签