Last active
August 29, 2015 14:27
-
-
Save bh3605/73e6d25b9ffe9243c0b8 to your computer and use it in GitHub Desktop.
Figures out application compile date
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const PeHeaderOffset as integer = 60 | |
const LinkerTimestampOffset as integer = 8 | |
dim filePath = System.Reflection.Assembly.GetExecutingAssembly().location | |
dim b(2047) as byte | |
dim s as IO.FileStream = new IO.FileStream(filePath, IO.FileMode.Open, IO.FileAccess.Read) | |
try | |
s.Read(b, 0, 2048) | |
finally | |
if not s is nothing | |
s.Close() | |
End If | |
end try | |
dim i as integer = BitConverter.ToInt32(b, PeHeaderOffset) | |
dim SecondsSince1970 as long = BitConverter.ToInt64(b, i + LinkerTimestampOffset) | |
dim dt as new DateTime(1970, 1, 1, 0, 0, 0) | |
dt = dt.AddSeconds(SecondsSince1970) | |
dt = dt.AddHours(TimeZone.CurrentTimeZone.GetUtcOffset(dt).Hours) | |
me.labelCompileDate.text = dt.ToShortDateString() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment