是否有人使用过pywin32 pywintype。DosDateTimetoTime将DOS压缩的日期/时间结构转换为Python中可读的时间格式?
我找不到太多关于如何使用此函数、需要什么参数以及格式的文档。
我正在编写一个脚本,从旧的DOS备份文件中提取文件,基本上是试图复制旧的DOS还原命令。我正在根据找到的备份文件的格式提取文件http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/dos/restore/brtecdoc.htm
谢谢,Jay
它采用两个参数(16位整数),这两个参数与DosDateTimeToFileTime
您可以在pywin32:的源代码PyWinTypesmodule.cpp中看到
static PyObject *PyWin_DosDateTimeToTime(PyObject *self, PyObject *args)
{
WORD wFatDate, wFatTime;
if (!PyArg_ParseTuple(args, "hh", (WORD *)&wFatDate, (WORD *)&wFatTime))
return NULL;
FILETIME fd;
If (!DosDateTimeToFileTime(wFatDate, wFatTime, &fd))
return PyWin_SetAPIError("DosDateTimeToFileTime");
}
这些必须是MSDN链接中描述的格式,为了方便起见,相关部分复制如下:
wFatDate [in]
The MS-DOS date. The date is a packed value with the following format.
Bits Description
0-4 Day of the month (1–31)
5-8 Month (1 = January, 2 = February, and so on)
9-15 Year offset from 1980 (add 1980 to get actual year)
wFatTime [in]
The MS-DOS time. The time is a packed value with the following format.
Bits Description
0-4 Second divided by 2
5-10 Minute (0–59)
11-15 Hour (0–23 on a 24-hour clock)