一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

使用EventLog控件向事件查看器中写出事件方法。

时间:2008-01-12 编辑:简简单单 来源:一聚教程网

'请先从组件中拖一个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

热门栏目