Krzysztof Narkowicz

Visual C++ linker timestamp

Advertisements

Nice trick to get build’s timestamp at runtime (Visual C++ only):

</pre>
EXTERN_C IMAGE_DOS_HEADER __ImageBase;

(...)

IMAGE_NT_HEADERS const* ntHeader
= (IMAGE_NT_HEADERS*) ( (char*) &__ImageBase + __ImageBase.e_lfanew );
DWORD const timeStamp = ntHeader->FileHeader.TimeDateStamp;
<pre>

It’s not very portable, but it doesn’t require any additional recompilation (as __DATE__ __TIME__ macros do).

Advertisements

Advertisements