如何使用VBA在Windows XP中获得空闲时间? [英] How to get the idle time in Windows XP using VBA?

查看:140
本文介绍了如何使用VBA在Windows XP中获得空闲时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I would like to know the current idle time from user input on a given Windows XP machine programmatically. I am using VBA in MS Access. What options do I have?

推荐答案

我使用以下方法来获取解决方案.

I used the following to obtain the solution.

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

系统的其他部分可能处于空闲状态,例如

There are other parts of the system which can be idle such as,

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

要了解有关性能和其他空闲类型的更多信息,请参见此处.

To find out more regarding performance and other idle types see this SO post here.

这篇关于如何使用VBA在Windows XP中获得空闲时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆