用VB编写一个自动关机程序
就是在WINDOWS有一段时间没操作就关机的那种程序在线等能有诠释吗?尤其是前面的那几段OptionExplicitPrivateDeclareFunctionGetLa...
就是在WINDOWS 有一段时间没操作就关机的那种程序
在线等
能有诠释吗?
尤其是前面的那几段
Option Explicit
Private Declare Function GetLastInputInfo Lib "user32" (plii As LASTINPUTINFO) As Boolean
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Type LASTINPUTINFO
cbSize As Long
dwTime As Long
End Type
Dim lii As LASTINPUTINFO
能帮我诠释下这些代码吗 展开
在线等
能有诠释吗?
尤其是前面的那几段
Option Explicit
Private Declare Function GetLastInputInfo Lib "user32" (plii As LASTINPUTINFO) As Boolean
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Type LASTINPUTINFO
cbSize As Long
dwTime As Long
End Type
Dim lii As LASTINPUTINFO
能帮我诠释下这些代码吗 展开
2个回答
展开全部
Option Explicit
Private Declare Function GetLastInputInfo Lib "user32" (plii As LASTINPUTINFO) As Boolean
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Type LASTINPUTINFO
cbSize As Long
dwTime As Long
End Type
Dim lii As LASTINPUTINFO
Private Sub Form_Load()
Timer1.Interval = 1000
lii.cbSize = Len(lii)
End Sub
Private Sub Timer1_Timer()
If GetLastInputInfo(lii) Then
If (GetTickCount - lii.dwTime) / 60000 >= 10 Then '10分钟没操作立即关机
Shell "shutdown -s"
End If
End If
End Sub
Private Declare Function GetLastInputInfo Lib "user32" (plii As LASTINPUTINFO) As Boolean
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Type LASTINPUTINFO
cbSize As Long
dwTime As Long
End Type
Dim lii As LASTINPUTINFO
Private Sub Form_Load()
Timer1.Interval = 1000
lii.cbSize = Len(lii)
End Sub
Private Sub Timer1_Timer()
If GetLastInputInfo(lii) Then
If (GetTickCount - lii.dwTime) / 60000 >= 10 Then '10分钟没操作立即关机
Shell "shutdown -s"
End If
End If
End Sub
参考资料: VB探讨超级群 48029944
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询