日期:2008-07-06  浏览次数:20424 次

'请先从组件中拖一个EventLog的控件到的你的Form上

'我用一个命令按钮来执行写入操作。
   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        '如果没有存在事件源的话就新建一个
        If Not EventLog.SourceExists("WriteToEvent") Then
            EventLog.CreateEventSource("WriteToEvent", "Application")  'Application是表示放于应用程序事件中
        End If
        EventLog1.Source = "WriteToEvent"
        EventLog1.WriteEntry("在这里我执行一个写入测试。")  '执行写入操作。
    End Sub