记载Windows使用的时间
Private Sub Form_Load()
Left = -10000
Top = -10000
Open "c:\apps\log.txt" For Append As #1
Print #1, "On: " & CStr(Now)
Close #1
End Sub
Private Sub Form_Unload(Cancel As Integer)
Open "c:\apps\log.txt" For Append As #1
Print #1, "Off:" & CStr(Now)
Close #1
End
End Sub
Dim winHwnd As Long
Dim RetVal As Long
winHwnd = FindWindow(vbNullString, "Calculator")
Debug.Print winHwnd
If winHwnd <> 0 Then
RetVal = PostMessage(winHwnd, WM_CLOSE, 0&, 0&)
If RetVal = 0 Then
MsgBox "置入消息错误!"
End If
Else
MsgBox "Calculator没有打开!"
End If