Getting the compile date/time of the current EXE

Every Windows executable (.EXE) contains the compile date/time stamp of the executable. In order to retrieve that datetime, it is advised to use the function GetTimestampForLoadedLibrary. The function returns the compile date/time in UTC time, and in UNIX format (number of seconds since Jan 1st, 1970). Here is a handy C function that will allow you to get the compile date/time in either UTC time or local time. Please do not attempt to "Direct_Input" your EXE and read from some magical offset (0x48 for VDF) because you are at the mercy of the linker implementation (for typical Visual Studio C++ 6 program, the offset is 0xE0 because the C++ linker generate a longer DOS stub). Also note that on line 30, the reason for using 0x400000 because all EXEs get loaded to that virtual address base for all Win32 programs. If you use the hInstance from the DLL, you would be getting the compile time of the DLL instead of the EXE. Anyway, put the following code in your DLL and then you can consume it in VDF.

void TimeStampToSysTime(DWORD Unix,SYSTEMTIME* SysTime, BOOL bLocal)
{
	SYSTEMTIME S;
	DWORDLONG FileReal,UnixReal,LocalReal;
	FILETIME* lpFileTime;
	S.wYear=1970;
	S.wMonth=1;
	S.wDay=1;
	S.wHour=0;
	S.wMinute=0;
	S.wSecond=0;
	S.wMilliseconds=0;
	SystemTimeToFileTime(&S,(FILETIME*)&FileReal);
	UnixReal = Unix;
	UnixReal*= 10000000;
	FileReal+=UnixReal;
	if (bLocal)
	{
		FileTimeToLocalFileTime((FILETIME*)&FileReal,(FILETIME*)&LocalReal);
		lpFileTime = (FILETIME*)&LocalReal;
	}
	else lpFileTime = (FILETIME*)&FileReal;
	FileTimeToSystemTime(lpFileTime,SysTime);
}

EXTERN_C void WINAPI GetModuleTimeStamp(SYSTEMTIME* ls, BOOL bLocal)
{
	
	DWORD timestamp;
	timestamp = GetTimestampForLoadedLibrary((HINSTANCE)0x400000);
	TimeStampToSysTime(timestamp,ls,bLocal);
}