2017-11-20 27 views
0

関数Watcher_EventArrivedが機能していません。
私も参照を追加しましたが、まだ動作していません。EventArrivedがManagementEventWatcher vb.Netで動作しません

enter image description here

Dim watcher As ManagementEventWatcher 

Public Sub Main() 
    Dim monitoredProcess = "Notepad.exe" 

    Dim query As WqlEventQuery = New WqlEventQuery("__InstanceCreationEvent", New TimeSpan(0, 0, 1), "TargetInstance isa ""Win32_Process"" And TargetInstance.Name = """ & monitoredProcess & """") 

    watcher = New ManagementEventWatcher() 
    watcher.Query = query 

    'This starts watching asynchronously, triggering EventArrived events every time a new event comes in. 
    'You can do synchronous watching via the WaitForNextEvent() method 
    watcher.Start() 

End Sub 

Public Sub Watcher_EventArrived(sender As Object, e As EventArrivedEventArgs) Handles watcher.EventArrived 
    Console.WriteLine("Working") 
End Sub 

答えて

関連する問題