Follow these steps:
1. Use kequerysystemtime () to obtain the current GMT system time. This is a count from 1601-01-01 (unit: 100ns ).
2. Call exsystemtimetolocaltime () to convert the GMT system time value to the local system time in the current time zone.
3. Use rtltimetotimefields () to convert the system time value to the format of Year: Month: Day: hour: minute: Second, Which is saved in a time_fields structure.
Typedef struct time_fields
{
Cshort year;
Cshort month;
Cshort Day;
Cshort hour;
Cshort minute;
Cshort second;
Cshort milliseconds;
Cshort weekday;
} Time_fields;
Sample Code to obtain the time string function:
(This function will later use: Windows Driver: to output debugging information to the file like dbuplintf)
(PS: is there a better format for source code)
//----------------------------------------------------------------------
//
// Getcurrenttimestring
//
// Get current time string. (Format: % d-% 02d-% 02d % 02d: % 02d: % 02d)
//
//----------------------------------------------------------------------
Pchar
Getcurrenttimestring ()
{
Static char sztime [128];
Large_integer systemtime;
Large_integer localtime;
Time_fields timefiled;
Kequerysystemtime (& systemtime );
Exsystemtimetolocaltime (& systemtime, & localtime );
Rtltimetotimefields (& localtime, & timefiled );
Sprintf (sztime, "% d-% 02d-% 02d % 02d: % 02d: % 02d"
, Timefiled. Year
, Timefiled. Month
, Timefiled. Day
, Timefiled. Hour
, Timefiled. Minute
, Timefiled. Second
);
Return sztime;
}