473,378 Members | 1,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Build date

Is there a way for my EXE to tell when it was built?

The idea is to write a copyright date that shows "Copyright 2005-" and then
the date the EXE was last built

-baylor
Jul 22 '05 #1
7 2615
baylor <ba****@discussions.microsoft.com> wrote:
Is there a way for my EXE to tell when it was built?

The idea is to write a copyright date that shows "Copyright 2005-" and then
the date the EXE was last built


There's a 4-byte value beginning at byte 0x88 in all PE files which is
the timestamp. It's the number of seconds since 1970 that elapsed
before the file was created.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 22 '05 #2
Jon Skeet [C# MVP] <sk***@pobox.com> wrote in
news:MP************************@msnews.microsoft.c om:
baylor <ba****@discussions.microsoft.com> wrote:
Is there a way for my EXE to tell when it was built?

The idea is to write a copyright date that shows "Copyright 2005-" and then the date the EXE was last built


There's a 4-byte value beginning at byte 0x88 in all PE files which is
the timestamp. It's the number of seconds since 1970 that elapsed
before the file was created.


Sorry, 0x88 might be true for some files, but definitely not for all.
The time stamp is relative to the PE exe header, which is after the
old DOS executable header and the DOS executable stub (which can have any
size).
The every segment has it's own timestamp.
For example Noepad.exe (Win2K, SP4) has the file timestamp at 0xE0.

See http://tuts4you.com/tutorials/PE-
Headers/Portable.Executable.File.Format.htm
or search for PE file format.

--
Mihai Nita [Microsoft MVP, Windows - SDK]
------------------------------------------
Replace _year_ with _ to get the real email
Jul 22 '05 #3
Mihai N. <nm**************@yahoo.com> wrote:
Sorry, 0x88 might be true for some files, but definitely not for all.
The time stamp is relative to the PE exe header, which is after the
old DOS executable header and the DOS executable stub (which can have any
size).
The every segment has it's own timestamp.
For example Noepad.exe (Win2K, SP4) has the file timestamp at 0xE0.

See http://tuts4you.com/tutorials/PE-
Headers/Portable.Executable.File.Format.htm
or search for PE file format.


I stand corrected - although according to the CLI spec, the DOS
executable stub must always be exactly 128 bytes. Whether the PE file
header comes immediately after the DOS stub is a different matter, of
course - and by the looks of it, adding 8 to the value specified at
position 0x3c is the way to go. (Mind you, that would suggest that the
file timestamp of notepad is at 0xe8, not 0xe0.)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 22 '05 #4
I use the exe file date time:

Microsoft.VisualBasic.FileDateTime(Application.Exe cutablePath).ToString("yyyy/MM/dd HH:mm:ss")

"baylor" wrote:
Is there a way for my EXE to tell when it was built?

The idea is to write a copyright date that shows "Copyright 2005-" and then
the date the EXE was last built

-baylor

Jul 22 '05 #5
> I stand corrected - although according to the CLI spec, the DOS
executable stub must always be exactly 128 bytes. Whether the PE file
header comes immediately after the DOS stub is a different matter, of
course - and by the looks of it, adding 8 to the value specified at
position 0x3c is the way to go. (Mind you, that would suggest that the
file timestamp of notepad is at 0xe8, not 0xe0.)


You might be right about the CLI (meaning .NET ext files)
But for non-CLI executables this is definitely not true.
Notepad.exe was just an example. But I have seen applications where
the DOS executable was a full working version of the application.
An example is hiew (Hacker's View).

I thing the only 100% safe way is to get the .exe documentation
a do a proper parser. I not that difficult.
--
Mihai Nita [Microsoft MVP, Windows - SDK]
------------------------------------------
Replace _year_ with _ to get the real email
Jul 22 '05 #6
baylor wrote:

Is there a way for my EXE to tell when it was built?

The idea is to write a copyright date that shows "Copyright 2005-" and then
the date the EXE was last built


According to Don Box (ISBN 0-201-73411-7) page 24, if you use an
AssemblyVersion attribute like

[assembly: AssemblyVersion("1.0.*")]

the third component of the version (major.minor.build.revision) is the
number of days since 2/1/2000.

--

www.midnightbeach.com
Jul 22 '05 #7
> > Is there a way for my EXE to tell when it was built?

The idea is to write a copyright date that shows "Copyright 2005-" and then
the date the EXE was last built


According to Don Box (ISBN 0-201-73411-7) page 24, if you use an
AssemblyVersion attribute like

[assembly: AssemblyVersion("1.0.*")]

the third component of the version (major.minor.build.revision) is the
number of days since 2/1/2000.


And, since the revision is the seconds since midnight / 2:

/// <summary>
/// Returns build date/time, assuming Version was specified as AssemblyVersion("1.0.*") (or any other major.minor)
/// </summary>
/// <param name="V">A Version instance, with build date/time info in build.revision fields</param>
/// <remarks>
/// Date/time does not honor daylight savings time.
/// </remarks>
public static DateTime BuildDateTime(Version V)
{
return new DateTime(2000, 2, 1) +
new TimeSpan(V.Build, 0, 0, V.Revision * 2);
}

Note that the timestamp is currently 1 hr off - I **assume** this
means that it uses the system's offset from UMT and is not daylight
savings time aware. That for builds from midnight to 1 AM (DST) it will
show the previous day. But I haven't tested this. ;-)

--

www.midnightbeach.com
Jul 22 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Shawn Wilson | last post by:
Hi, My host keeps messing things up and not telling me. I am trying to write a cron job that will test to make sure the "unusual" functions I use work and, if not, email me. I want it to send...
1
by: nom_du_pere | last post by:
The phpinfo function lists the system ... But is it the system that PHP was compiled on OR the system that PHP is executing on? I took a sneak peek at the source code and I am leaning toward the...
5
by: cameron | last post by:
Is it possible to get the build date, (not the version), of a dll? -Cam
7
by: dm_dal | last post by:
I have a solution in VS.Net 2003. It contains 1 - asp.net project(c#), 1 - c# class library project and 1 - db project. When I try to build the solution, I get the following error: Could not...
2
by: Roger Helliwell | last post by:
Hey gang, What's the best way to implement a Build version (or "last updated" date) in my web-app? I have a footer in my master page that displays the application's name and copyright info etc....
7
by: baylor | last post by:
Is there a way for my EXE to tell when it was built? The idea is to write a copyright date that shows "Copyright 2005-" and then the date the EXE was last built -baylor
3
by: nautonnier | last post by:
This may have been covered before but I didn't find anything after doing a google search. Does VS.NET 2005 have a way to put build or version numbers within aspx pages? I'm envisioning an...
2
by: Pieter | last post by:
Hi, How can I knwo the BuildDate from an application distributed by ClickOnce? When I use "System.IO.File.GetLastWriteTime(objAssembly.Location)" or...
7
by: eschneider | last post by:
I have a webservice which every time I build it keeps adding Crystal references into the web.config? <add assembly="CrystalDecisions.Shared, Version=10.2.3600.0, Culture=neutral,...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.