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!

Obtaining .exe creation date. 2

Status
Not open for further replies.

golyg

Programmer
Jul 22, 2002
319
US
Hello all,
I want to know if there is a way that I could "grab" the date the .exe was created and display it in the "About" dialog box for the user...?

TIA,
 
Code:
    cout << __DATE__ << " " << __TIME__ << endl;
Those two things are compiler generated "string" constants. So just create a string as part of your about, and it should do what you want

Code:
char *about = "This program was created on "
__DATE__
" at "
__TIME__
" by me";

--
 
Use GetFileVersionInfoSize(), GetFileVersionInfo() that give VS_VERSIONINFO, VS_FIXEDFILEINFO structures and there retrieve the following fields:
DWORD dwFileDateMS;
DWORD dwFileDateLS;
-obislavu-
 
Thanks to the both of you, great answers & great response time...

thanks so much
 
Great tip, Salem.

However, this will be the compile time of the file. Say I want to use this __DATE__ and __TIME__ in my About dialog, how can I force the file to always recompile (I don't want to always rebuild all my application, just the small cpp file where I use the __DATE__ for my about box). If the about box file does not recompile, then it will keep the previous compile's date/time :-(

Thanks,

Vincent
 
There are probably several ways to do this - probably better ways as well.
Create a pre-build step which removes the date.obj file. Since the build process will then detect it is missing, it will recompile date.cpp for you each time.

Normally, I wouldn't bother with trying to keep the about information exactly up to date. Any serious build for testing or release purposes would begin with a 'rebuild all' anyway, and that's sure to catch it.

obislavu's solution should also be considered, since the IDE knows about this - like auto incrementing the build number for example.

--
 
use GetModuleFilename to get the launched executable name at runtime and follow that obislavu said.

Ion Filipski
1c.bmp
 
Thanks guys. I was looking for a simple way to track the many copies of a program I use in my lab, so I will just go with the "Rebuild All" idea, which makes a lot of sense!

Vincent
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top