zoukankan      html  css  js  c++  java
  • [Windows 驱动开发] 获取时间

    开机时间

    void MyGetTickCount(PULONG  msec) //进行传出
    {
        LARGE_INTEGER la;
        ULONG MyInc;
        MyInc = KeQueryTimeIncrement(); //返回滴答数
    
        //下方 KeQueryTickCount 的宏的原型.
    
        KeQueryTickCount(&la);
        
        la.QuadPart *= MyInc;
        la.QuadPart /= 10000;
        
        *msec = la.LowPart;
    
    }
    

    当前时间

    PTCHAR GetTimeYMS()
    {
        //获取年月日.
        LARGE_INTEGER SystemTime;
        LARGE_INTEGER LocalTime;
        TIME_FIELDS TimeFiled;
        TCHAR *time_str = ExAllocatePoolWithTag(PagedPool, 32, 0);
    
        KeQuerySystemTime(&SystemTime);
        ExSystemTimeToLocalTime(&SystemTime,&LocalTime);
        RtlTimeToTimeFields(&LocalTime,&TimeFiled);
    #ifdef UNICODE
    #define RtlStringCchPrintf RtlStringCchPrintfW
    #else
    #define RtlStringCchPrintf RtlStringCchPrintfA
    #endif // UNICODE
    
        RtlStringCchPrintf(
            time_str,
            32,
            TEXT("%4d-%2d-%2d %2d-%2d-%2d"),
            TimeFiled.Year,
            TimeFiled.Month,
            TimeFiled.Day,              //年月日时分秒
            TimeFiled.Hour,
            TimeFiled.Minute,
            TimeFiled.Second);
        return time_str;
    }
    NTSTATUS DriverEntry(PDRIVER_OBJECT pDriverObj, PUNICODE_STRING pRegPath)
    {
        PTCHAR pTime = NULL;
        pDriverObj->DriverUnload = DriverUnLoad;
        pTime = GetTimeYMS();
    
        DbgPrint("%Ls \r\n", pTime);
        return STATUS_SUCCESS;
    }
    
  • 相关阅读:
    内存队列使用Channels
    笔记20210101mongodb
    管道式的开发模式
    企业级应用架构设计
    再入历史旧坑
    路径问题 再次记录
    mongdb驱动的问题
    使用Bumblebee记录
    我和小兔子不得不说的消息v2
    流程设计器jQuery + svg/vml(Demo7
  • 原文地址:https://www.cnblogs.com/csnd/p/15613332.html
Copyright © 2011-2022 走看看