【VB.NET】Windowsの起動と終了の時間を表示 イベントログ | 備忘録 (。・_・。)ノ
イベントログからの取得方法
Microsoft Visual Studio Express 2013 for Windows Desktop
Windows8 64bitではエラー

【VB.NET】Windowsの起動と終了の時間を表示

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Try
            Dim logs() As System.Diagnostics.EventLog
            logs = System.Diagnostics.EventLog.GetEventLogs()
            For Each log As EventLog In logs
                If log.LogDisplayName <> "システム" Then
                    Continue For
                End If
                For Each entry As EventLogEntry In log.Entries
                    Select Case entry.EventID     'entry.EventID 
                        Case 6005 ' 起動   
                            Console.WriteLine("起動" & entry.TimeWritten)
                        Case 6006 ' 終了   
                            Console.WriteLine("終了 " & entry.TimeWritten)
                            Console.WriteLine()
                        Case Else
                            Continue For
                    End Select
                Next entry
            Next log
            End
        Catch ex As System.Exception
            MsgBox(ex.Message)
            End
        End Try
    End Sub