从.exe获取编译日期和时间

sky*_*lla 5 c++ executable datetime compilation

我有可执行文件的全名和路径,例如C:\IW4\BIN\iw32.exe,并且想要提取该可执行文件的编译日期和时间.

我怎样才能做到这一点?我找不到合适的解决方案.

我的C++程序必须使用Borland C++ Builder在Windows下编译,如果该信息有任何价值.

编辑:我发现了一些示例代码,它的工作原理,感谢您的所有指示和提示!

守则是:

#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;
}
Run Code Online (Sandbox Code Playgroud)

其中提供以下输出:

Created: 2013-06-20 12:37:14
Size: 15098368
Run Code Online (Sandbox Code Playgroud)

mox*_*mox 3

您要查找的信息可以在可执行映像的IMAGE_FILE_HEADER中找到。您可以通过将字段指向图像中的偏移量来检索此信息(困难的方法)。另一种选择是使用图像帮助库