VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Write To Windows Event Log ...

by Gehan Fernando. (13 Submissions)
Category: Windows System Services
Compatability: VB.NET
Difficulty: Unknown Difficulty
Originally Published: Mon 17th September 2007
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Write To Windows Event Log ...

Rate Write To Windows Event Log ...




        WriteToEventLog("Hello Where Are U", EventLogEntryType.Information, "VB.Net Application", "Application")


    End Sub

    Private Function WriteToEventLog(ByVal Entry As String, ByVal LogEntryType As System.Diagnostics.EventLogEntryType, _
                                     Optional ByVal AppName As String = "VB.Net Application", _
                                     Optional ByVal LogName As String = "Application") As Boolean


        Dim objeventlog As New EventLog()

        Try
            If EventLog.SourceExists(AppName) = False Then
                EventLog.CreateEventSource(AppName, LogName)
            End If

            objeventlog.Source = AppName
            objeventlog.WriteEntry(Entry, LogEntryType)
        Catch ex As Exception
            MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Finally
            objeventlog.Dispose()
        End Try

    End Function

Download this snippet    Add to My Saved Code

Write To Windows Event Log ... Comments

No comments have been posted about Write To Windows Event Log .... Why not be the first to post a comment about Write To Windows Event Log ....

Post your comment

Subject:
Message:
0/1000 characters