Skip to content

Instantly share code, notes, and snippets.

@bh3605
Last active August 29, 2015 14:27
Show Gist options
  • Save bh3605/73e6d25b9ffe9243c0b8 to your computer and use it in GitHub Desktop.
Save bh3605/73e6d25b9ffe9243c0b8 to your computer and use it in GitHub Desktop.
Figures out application compile date
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