Notification when an instance of Win32_Process is created : Management « Windows « VB.Net Tutorial






Imports System
Imports System.Management

Public Class EventWatcherPolling
    Public Overloads Shared Function Main(ByVal args() As String) As Integer
        Dim query As String
        query = "SELECT * FROM __InstanceCreationEvent WITHIN 1 WHERE TargetInstance isa ""Win32_Process"""

        Dim eventOptions As New EventWatcherOptions
        eventOptions.Timeout = System.TimeSpan.MaxValue

        Dim watcher As New ManagementEventWatcher("root\CIMV2", query, eventOptions)

        Dim e As ManagementBaseObject = watcher.WaitForNextEvent()

        watcher.Stop()
        Return 0

    End Function
End Class








24.29.Management
24.29.1.Initialize an EnumerationOptions variable with an EnumerationOptions constructor and then gets all the instances of a WMI class and its subclasses.
24.29.2.Connect to a remote computer and displays information about the operating system on the remote computer.
24.29.3.Notification when an instance of Win32_Process is created
24.29.4.Synchronous consumption of events. The client is blocked while waiting for events.