寫 EventLog 方法
Imports System.Diagnostics Public Function WriteToEventLog(ByVal EventId As Integer, ByVal app As String, ByVal Entry As String) As Boolean Dim AppName As String = app Dim objEventLog As New EventLog() Dim EventType As EventLogEntryType = EventLogEntryType.Error Dim LogName As String = "Application" Try If Not EventLog.SourceExists(AppName) Then EventLog.CreateEventSource(AppName, LogName) End If objEventLog.Source = AppName objEventLog.WriteEntry(Entry, EventType, EventId) Return True Catch Ex As Exception Return False End Try End Function |