| 网站首页 | VB.Net实例分析 | .Net技术文摘 | 下载中心 | VB.Net书籍笔记 | .Net源码 | VBS脚本与组件调用 | Windows2008技术文摘 | 给我们留言 | 
最新公告:

  没有公告

您现在的位置: 乐博网 >> VB.Net实例分析 >> 实例学习笔记 >> 实例分析正文
最新推荐 更多内容
创建和删除事件日志(VB2010实例)
创建和删除事件日志(VB2010实例)
作者:Akyao    来源:乐博网收集     更新时间:2011-4-4

创建和删除事件日志(VB2010实例)

VB2010源码如下:

 

' Copyright (c) Microsoft Corporation. All rights reserved.
Public Class CreateDeleteForm
    Private Sub cmdCreateLog_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreateLog.Click
        Try
            ' Next check for the existence of the log that the user wants to create.
            If Not EventLog.Exists(txtLogNameToCreate.Text) Then
                ' If the event source is already registered we want to delete it
                ' before recreating it on the call to CreateEventSource
                If EventLog.SourceExists("Event Log Sample") Then
                    EventLog.DeleteEventSource("Event Log Sample")
                End If
                EventLog.CreateEventSource("Event Log Sample", txtLogNameToCreate.Text)
                MsgBox("Event log created.")
            Else
                MsgBox("Log already exists: " & txtLogNameToCreate.Text, MsgBoxStyle.OKOnly, Me.Text & " Error")
            End If
        Catch ex As Exception
            MsgBox("Unable to create event log.", MsgBoxStyle.OKOnly, Me.Text & " Error")
        End Try
    End Sub

    Private Sub cmdDeleteLog_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDeleteLog.Click
        Try
            If EventLog.Exists(txtLogNameToDelete.Text) Then
                'Next call the delete method of the log that the user wants to delete.
                EventLog.Delete(txtLogNameToDelete.Text)
                MsgBox("Event log deleted.")
            Else
                MsgBox("Log does not exist: " & txtLogNameToDelete.Text, MsgBoxStyle.OKOnly, Me.Text & " Error")
            End If
        Catch ex As Exception
            MsgBox("Unable to delete event log.", MsgBoxStyle.OKOnly, Me.Text & " Error")
        End Try
    End Sub

    Private Sub CloseToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseToolStripMenuItem.Click
        Me.Close()
    End Sub
End Class

  • 上一篇:

  • 下一篇:
  • 【字体: 】【打印此文】【关闭窗口
      相关文章:(只显示最新16条)
    写入事件日志(VB2010实例)
    读取事件日志(VB2010实例)
    COMPort编程(VB2010实例)
    读取大文件(VB2010实例)
    读取文件(VB2010实例)
    文件移动(VB2010实例)
    获取驱动器磁盘信息(VB2010实例)
    目录搜索和目录查找(VB2010实例)
    文件搜索和文件查找(VB2010实例)
    选择文件目录(VB2010实例)
    删除文件(VB2010实例)
    复制文件(VB2010实例)
    复制目录(VB2010实例)
    DateTime(VB2010实例)
    arrays(VB2010实例)
    APICalls(VB2010实例)

    | 设为首页 | 加入收藏 | 联系站长 | | 友情链接 | 版权申明 |
    乐博网欢迎各种媒体转载我们的原创作品[转载请注明出处];我们鼓励更多VB.Net开发者一起加入研究与探讨;如发现文章访问错误、内容错误或版权疑问、内容有违相关法律(如涉及政治、色情、反动或散布虚假有害信息)等情况,请及时向我们举报,我们将及时纠正!
    联系邮箱:Shiny#vip.qq.com (#替换为@) QQ交流群: 40797788 [闽ICP备05014267号]