NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

EventLog.DeleteEventSource

Removes an application's event source registration from the event log.

Overload List

Removes the application's event source registration from the specified computer.

[Visual Basic] Overloads Public Shared Sub DeleteEventSource(String, String)
[C#] public static void DeleteEventSource(String, String);
[C++] public: static void DeleteEventSource(String*, String*);
[JScript] public static function DeleteEventSource(String, String);

Removes the event source registration from the event log of the local computer.

[Visual Basic] Overloads Public Shared Sub DeleteEventSource(String)
[C#] public static void DeleteEventSource(String);
[C++] public: static void DeleteEventSource(String*);
[JScript] public static function DeleteEventSource(String);

Example [Visual Basic]

The following example closes an event log specified by the source "mySource", and deletes the source. This does not delete the log to which the source is registered (use Delete for that), only the source and its registration. The log can be opened again by creating another source using CreateEventSource and registering it to the log.

The local event log instance is created only in order to call Close on the log. All other methods used are static (in Visual Basic Shared) and should be called on the EventLog class itself.

Import the System.Diagnostics namespace for this example.

Note   This example shows how to use one of the overloaded versions of DeleteEventSource. For other examples that may be available, see the individual overload topics.

[Visual Basic]

Private Sub CloseLog()
    'Declare and instantiate an event log.
    Dim evtLog As EventLog
    evtLog = New EventLog
    'Declare a source called "mySource"
    Dim source As String
    source = "mySource"

    'Verify that the source exists.
    If EventLog.SourceExists(source) Then
        'Connect the event log to the source.
        evtLog.Source = source
        'Close the log so that it does not receive new entries.
        evtLog.Close()
        EventLog.DeleteEventSource(source)
    End If
End Sub

See Also

EventLog Class | EventLog Members | System.Diagnostics Namespace