【问题标题】:How to get the idle time in Windows XP using VBA?如何使用 VBA 在 Windows XP 中获取空闲时间?
【发布时间】:2011-02-05 01:31:51
【问题描述】:

我想以编程方式从给定 Windows XP 机器上的用户输入中了解当前空闲时间。我在 MS Access 中使用 VBA。我有什么选择?

【问题讨论】:

    标签: ms-access vba winapi idle-processing


    【解决方案1】:

    我使用以下方法获得了解决方案。

    Private Declare Function GetTickCount Lib "kernel32" () As Long
    Private Declare Function GetLastInputInfo Lib "user32" (plii As Any) As Long
    
    Private Type LastInputInformation
    
        cbSize As Long
    
        dwTime As Long
    
    End Type
    
    Public Function GetUsersIdleTime() As Long
    
        Dim lii As LastInputInformation
    
        lii.cbSize = Len(lii)
    
        Call GetLastInputInfo(lii)
    
        GetUsersIdleTime = FormatNumber((GetTickCount() - lii.dwTime) / 1000, 2)
    
    End Function
    

    系统的其他部分可以空闲,例如,

    • CPU
    • 磁盘
    • 网络
    • 其他设备

    要了解有关性能和其他空闲类型的更多信息,请参阅此 SO 帖子 here

    【讨论】:

    • 这有点超出了问题的范围,但是仁慈的发帖人能否解释一下“空闲时间”是什么?听起来很有用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-09-23
    • 1970-01-01
    • 2011-04-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多