darkme
驱动牛犊
驱动牛犊
  • 注册日期2004-07-17
  • 最后登录2006-03-15
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:1229回复:1

问一个很弱的问题,如何在驱动程序中显示系统时间。

楼主#
更多 发布于:2004-08-09 15:41
我要编写一个程序,需要用到超时设置,所以需要记录系统时间。请问各位大侠,如何获得系统时间。或者推荐一个好的方法。多谢。

最新喜欢:

WY.lslrtWY.lsl...
darkme
驱动牛犊
驱动牛犊
  • 注册日期2004-07-17
  • 最后登录2006-03-15
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2004-08-11 09:43
sigh~~~~~~~~,自己给自己回答吧
//所有的变量必须在使用之前声明,这是标准C的规则,我怎么又忘记了呢。咳~~~~

LARGE_INTEGER *currentTime = NULL;
TIME_FIELDS *timeFields = NULL;

currentTime = (LARGE_INTEGER *) ExAllocatePool(NonPagedPool, sizeof(LARGE_INTEGER));

timeFields = (TIME_FIELDS *) ExAllocatePool(NonPagedPool, sizeof(TIME_FIELDS));

if( (currentTime == NULL)||(timeFields == NULL) )
{
DbgPrint("Problem reserving memory\n");
return STATUS_INSUFFICIENT_RESOURCES;
}
else
{
DbgPrint("Reserving memory OK\n");
KeQuerySystemTime( currentTime );
RtlTimeToTimeFields(currentTime, timeFields);
//显示采用long interger表示的时间
DbgPrint("Current time (as integer):\t%ld\n",(*currentTime));
//采用我们比较容易理解的时间显示方式
DbgPrint("YEAR:\t%d\n",(*timeFields).Year);
DbgPrint("Month:\t%d\n",(*timeFields).Month);
DbgPrint("Day:\t%d\n",(*timeFields).Day);
DbgPrint("Hour:\t%d\n",(*timeFields).Hour);
DbgPrint("Minute:\t%d\n",(*timeFields).Minute);
DbgPrint("Second:\t%d\n",(*timeFields).Second);
DbgPrint("Milliseconds:\t%d\n",(*timeFields).Milliseconds);
DbgPrint("Weekday:\t%d\n",(*timeFields).Weekday);
ExFreePool(currentTime);
ExFreePool(timeFields);
DbgPrint("Free memory OK\n");
游客

返回顶部