2010-04-07 82 views

回答

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 

有该系统可以处于空闲状态的其他部分,如

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

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

+0

这有点超出了问题的范围,但是可以给一个仁慈的海报解释什么是'空闲时间'?这听起来很有用。 – PowerUser 2010-04-07 13:27:04

+0

感谢您的链接。 – PowerUser 2010-04-07 14:58:52