473,471 Members | 4,687 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 2630
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.