![]() |
#2
zxdw5202011-03-20 10:44
|

Public Structure LASTINPUTINFO '定义数据类型
Public cbSize '添加的两个成员
Public dwTime
End Structure
===================================
Public Declare Function GetLastInputInfo Lib "user32 " (ByRef LASTINPUTINFO As LASTINPUTINFO) As Boolean
============================================
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim A As LASTINPUTINFO, 启动时间 As Integer, 上一次活动时间 As Integer, 已闲置时间 As Integer, 地址
地址 = WebBrowser1.Url
A.dwTime = 0
A.cbSize = 8
启动时间 = Environment.TickCount / 1000
GetLastInputInfo(A)
cs1.Text = 启动时间
上一次活动时间 = A.dwTime / 1000
cs2.Text = 上一次活动时间
已闲置时间 = 启动时间 - 上一次活动时间
cs3.Text = 已闲置时间
If 已闲置时间 = 5 Then
MsgBox("时间到了!")
End If
End Sub
Public cbSize '添加的两个成员
Public dwTime
End Structure
===================================
Public Declare Function GetLastInputInfo Lib "user32 " (ByRef LASTINPUTINFO As LASTINPUTINFO) As Boolean
============================================
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim A As LASTINPUTINFO, 启动时间 As Integer, 上一次活动时间 As Integer, 已闲置时间 As Integer, 地址
地址 = WebBrowser1.Url
A.dwTime = 0
A.cbSize = 8
启动时间 = Environment.TickCount / 1000
GetLastInputInfo(A)
cs1.Text = 启动时间
上一次活动时间 = A.dwTime / 1000
cs2.Text = 上一次活动时间
已闲置时间 = 启动时间 - 上一次活动时间
cs3.Text = 已闲置时间
If 已闲置时间 = 5 Then
MsgBox("时间到了!")
End If
End Sub
上一次活动时间 的值一直获取不到,一直都是0
[ 本帖最后由 zxdw520 于 2011-3-19 20:51 编辑 ]