1

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

4

1 回答 1

4

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

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

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

  • 中央处理器
  • 磁盘
  • 网络
  • 其他设备

要了解有关性能和其他空闲类型的更多信息,请在此处查看此 SO 帖子。

于 2010-04-07T00:47:22.797 回答