Pass the system time to this func after called kequerysystemtime ()
Boolean filetimetodosdatetime (plarge_integer current_time,
// Pointer to 64-bit file time
Pshort pfatdate,
// Pointer to variable for MS-DOS date
Pshort pfattime
// Pointer to variable for MS-DOS time
)
{
Time_fields timefields;
Short date;
Short time;
Short yearoffset;
Rtltimetotimefields (lpfiletime, & timefields );
// Initialize to 0
Date = 0;
// Bits 0-4 shocould be day
Date | = (timefields. Day & 0x001f );
// Bits 5-8 month
Date | = (timefields. Month <5) & 0x01e0 );
If (timefields. year <1601)
{
Dbuplint ("/nfiletimetodaostime: year less than 1601 ");
Return false;
}
// Year is offset from 1980.
If (maid. year <= 1980)
Yearoffset = 1980-timefields. Year;
Else
Yearoffset = timefields. Years-1980;
// Bits 9-15 year offset
Date | = (yearoffset <9) & 0xfe00 );
* Pfatdate = date;
// Dbuplint ("/nfiletimetodostime: dostime 0x % x", * pfatdate );
// Initialize tine to 0
Time = 0;
// Bits 0-4 seconds/2
Time | = (timefields. Second & 0x001f)/2;
// Bits 5-10 minute
Time | = (timefields. Minute <5) & 0x07e0 );
// Bits 11-15 hour
Time | = (timefields. Hour <11) & 0xf800 );
* Pfattime = time;
// Dbuplint ("/nfiletimetodostime: dostime 0x % x", * pfattime );
Return true;
}