MyGetCurrentTime 驱动获取当前时间
2011-04-22 23:17
344 查看
MyGetCurrentTime 驱动获取当前时间
//比 __TIME__ 精准
VOID MyGetCurrentTime()
{
LARGE_INTEGER snow,now;
TIME_FIELDS now_fields;
NTSTATUS status;
//获取标准时间
KeQuerySystemTime(&snow);
//转为当地时间
ExSystemTimeToLocalTime(&snow,&now);
//转为可视时间
RtlTimeToTimeFields(&now,&now_fields);
/*
status = RtlStringCchPrintfW(time_str,
32*2,
L"当前时间: %4d-%2d-%2d-%2d %2d-%2d-%2d",
now_fields.Year,
now_fields.Month,
now_fields.Day,
now_fields.Hour,
now_fields.Minute,
now_fields.Second);
*/
DbgPrint("当前时间: %04d-%02d-%02d %02d:%02d:%02d",
now_fields.Year,
now_fields.Month,
now_fields.Day,
now_fields.Hour,
now_fields.Minute,
now_fields.Second);
}
//内核休眠函数
#define DELAY_ONE_MICROSECOND (-10)
#define DELAY_ONE_MILLISECOND (DELAY_ONE_MICROSECOND*1000)
VOID MySleep(LONG msec) //毫秒
{
LARGE_INTEGER my_interval;
my_interval.QuadPart = DELAY_ONE_MILLISECOND;
my_interval.QuadPart *=msec;
KeDelayExecutionThread(KernelMode,0,&my_interval);
DbgPrint("正在执行函数MySleep!/r/n");
}
//比 __TIME__ 精准
VOID MyGetCurrentTime()
{
LARGE_INTEGER snow,now;
TIME_FIELDS now_fields;
NTSTATUS status;
//获取标准时间
KeQuerySystemTime(&snow);
//转为当地时间
ExSystemTimeToLocalTime(&snow,&now);
//转为可视时间
RtlTimeToTimeFields(&now,&now_fields);
/*
status = RtlStringCchPrintfW(time_str,
32*2,
L"当前时间: %4d-%2d-%2d-%2d %2d-%2d-%2d",
now_fields.Year,
now_fields.Month,
now_fields.Day,
now_fields.Hour,
now_fields.Minute,
now_fields.Second);
*/
DbgPrint("当前时间: %04d-%02d-%02d %02d:%02d:%02d",
now_fields.Year,
now_fields.Month,
now_fields.Day,
now_fields.Hour,
now_fields.Minute,
now_fields.Second);
}
//内核休眠函数
#define DELAY_ONE_MICROSECOND (-10)
#define DELAY_ONE_MILLISECOND (DELAY_ONE_MICROSECOND*1000)
VOID MySleep(LONG msec) //毫秒
{
LARGE_INTEGER my_interval;
my_interval.QuadPart = DELAY_ONE_MILLISECOND;
my_interval.QuadPart *=msec;
KeDelayExecutionThread(KernelMode,0,&my_interval);
DbgPrint("正在执行函数MySleep!/r/n");
}
相关文章推荐
- System.currentTimeMillis,getTimeInMillis与new Date().getTime获取当前时间戳耗时比较
- System.currentTimeMillis,getTimeInMillis与new Date().getTime获取当前时间戳耗时比较
- System.currentTimeMillis,getTimeInMillis与new Date().getTime获取当前时间戳耗时比较
- System.currentTimeMillis,getTimeInMillis与new Date().getTime获取当前时间戳耗时比较
- System.currentTimeMillis,getTimeInMillis与new Date().getTime获取当前时间戳耗时比较
- System.currentTimeMillis,getTimeInMillis与new Date().getTime获取当前时间戳耗时比较
- System.currentTimeMillis,getTimeInMillis与new Date().getTime获取当前时间戳耗时比较
- System.currentTimeMillis,getTimeInMillis与new Date().getTime获取当前时间戳耗时比较
- System.currentTimeMillis,getTimeInMillis与new Date().getTime获取当前时间戳耗时比较
- CTime::GetCurrentTime();获取当前时间
- System.currentTimeMillis,getTimeInMillis与new Date().getTime获取当前时间戳耗时比较
- C++ Get Current Time 获取当前时间
- System.currentTimeMillis,getTimeInMillis与new Date().getTime获取当前时间戳耗时比较
- System.currentTimeMillis,getTimeInMillis与new Date().getTime获取当前时间戳耗时比较
- System.currentTimeMillis,getTimeInMillis与new Date().getTime获取当前时间戳耗时比较
- System.currentTimeMillis,getTimeInMillis与new Date().getTime获取当前时间戳耗时比较
- System.currentTimeMillis,getTimeInMillis与new Date().getTime获取当前时间戳耗时比较
- System.currentTimeMillis,getTimeInMillis与new Date().getTime获取当前时间戳耗时比较
- System.currentTimeMillis,getTimeInMillis与new Date().getTime获取当前时间戳耗时比较
- System.currentTimeMillis,getTimeInMillis与new Date().getTime获取当前时间戳耗时比较