How to get the current system time in the WDM driver

zhaozj2021-02-16  52

How to get the current system time in the WDM driver?

You can follow these steps:

1. Get the current GMT System Time with KequerySystemTime (). This is a count since 1601-01-01 (unit is 100ns).

2. If you are Win2000 / XP, call EXSYSTEMTIMETOLOCALTIME () Convert GMT System Time Value into the local system time of the current time zone. If it is under Win9X, you cannot call EXSYSTEMTIMETOLOCALTIME (), you can do this: Query registry key (REG_DWORD)

HKEY_LOCAL_MACHINE / SYSTEM / CURRENTCONTROLSET / CONTROL / TIMEZONEINFORMATION / ACTIVETIMEBIAS

Get the Time-Zone Bias value, then subtract the Bias with GMT System Time to get the Local System Time.

3. Convert System Time Value into the Year: Month: Time: Time: Save in a Time_Fields structure in the form of a day: day:

Typedef strunt time_fields {cshort year; cshort month; cshort day; cshort hour; cshort minute; cshort second; cshort milliseconds; cshort weekday;} Time_fields;

转载请注明原文地址:https://www.9cbs.com/read-18147.html

New Post(0)