This code shows how to read event logs in VB.NET
Private Sub frmRead_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try Dim CurrentLog As EventLog For Each CurrentLog In EventLog.GetEventLogs() lstEntryType.Items.Add(CurrentLog.LogDisplayName) Next lstEntryType.SelectedIndex = 0 Catch secEx As SecurityException MessageBox.Show("Error reading an event log: this may be due to a lack of appropriate permissions." & vbCrLf & secEx.Message, _ "Lack of Permissions", _ MessageBoxButtons.OK, _ MessageBoxIcon.Error) Catch ex As Exception MessageBox.Show("Error accessing logs on the local machine." & vbCrLf & ex.Message, _ "Error accessing logs.", _ MessageBoxButtons.OK, _ MessageBoxIcon.Error) End Try End Sub
|
No responses found. Be the first to respond and make money from revenue sharing program.
|