Private Sub button1_Click(sender As Object, e As EventArgs) MessageBox.Show(GetLastSystemShutdown().ToString()) End Sub Public Shared Function GetLastSystemShutdown() As DateTime Dim sKey As String = "System\CurrentControlSet\Control\Windows" Dim key As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(sKey) Dim sValueName As String = "ShutdownTime" Dim val As Byte() = DirectCast(key.GetValue(sValueName), Byte()) Dim valueAsLong As Long = BitConverter.ToInt64(val, 0) Return DateTime.FromFileTime(valueAsLong) End Function
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)