windows driver 获取本地时间

#define ArrayLength 260
void MyGetLocalTime()
{
	LARGE_INTEGER li_system;
	LARGE_INTEGER li_Local;
	char strTime[ArrayLength] = {0};
	ANSI_STRING as;
	TIME_FIELDS tf;
	KeQuerySystemTime(&li_system);
	ExSystemTimeToLocalTime(&li_system, &li_Local);
	RtlTimeToTimeFields(&li_Local, &tf);

	RtlInitEmptyAnsiString(&as, strTime, ArrayLength);
	RtlStringCbPrintfA(as.Buffer, ArrayLength, "%d-%d-%d %d:%d:%d\n", tf.Year, tf.Month, tf.Day, tf.Hour, tf.Minute, tf.Second);
	KdPrint(("%s\n", as.Buffer));
}

 

版权声明:本文为博主原创文章,未经博主允许不得转载。

 

posted @ 2014-11-13 20:17  QQ76211822  阅读(291)  评论(0编辑  收藏  举报