Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get compilation Date & Time from .exe

I have the full name & path of an executable, e.g. C:\IW4\BIN\iw32.exe, and want to extract the compilation date and time of that executable.

How can I do this? I couldn't find any suitable solution.

My C++ program must compile under Windows using Borland C++ Builder, if that info is of any worth.

EDIT: I found some sample code and it works, thanks for all your pointers and hints!

The Code is :

#include <stdio.h>
#include <windows.h>

int main (int argc, char** argv)
{
    WIN32_FILE_ATTRIBUTE_DATA attr;
    SYSTEMTIME creation;

    if (argc < 2)
      return 1;
    GetFileAttributesEx(argv[1], GetFileExInfoStandard, &attr);
    FileTimeToSystemTime(&attr.ftLastWriteTime, &creation);
    printf("Created: %04d-%02d-%02d %02d:%02d:%02d\n"
       "Size: %d bytes\n",
       creation.wYear, creation.wMonth, creation.wDay,
       creation.wHour, creation.wMinute, creation.wSecond,
       attr.nFileSizeLow);

   return 0;
}

Which delivers following output :

Created: 2013-06-20 12:37:14
Size: 15098368
like image 221
skylla Avatar asked Oct 04 '22 18:10

skylla


1 Answers

The information your're looking for is to be found in the IMAGE_FILE_HEADER of the executable image. You can retrieve this information either by pointing the field by its offset in the image (the hard way). Another option would be to use the Image Help Library

like image 108
mox Avatar answered Oct 07 '22 19:10

mox