在VBA中是否有任何方法(如api),以确定Windows上次从待机状态恢复的时间等? 我不是要发动一个事件,只是能够在我需要的时候查找它。
答案 0 :(得分:0)
考虑到你的要求(不是试图发动事件),我应该告诉你不能这样做。 Althogh this link可以帮助你
编辑:
Imports Microsoft.Win32
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AddHandler SystemEvents.PowerModeChanged, AddressOf mypmc
End Sub
Public Sub mypmc(ByVal sender As Object, ByVal e As PowerModeChangedEventArgs)
Dim iFileNum As Integer 'File number for output text file.
strOutputFile = "c:\log.txt"
iFileNum = FreeFile
Open strOutputFile For Output As #iFileNum
If e.Mode = PowerModes.Suspend Then
Print #1, "Suspending" & TimeValue(Now)
End If
If e.Mode = PowerModes.Resume Then
Print #1, "Resuming" & TimeValue(Now)
End If
End Sub
End Class