public class WMIEventWatcher : ManagementEventWatcher
Public Class WMIEventWatcher
Inherits ManagementEventWatcher
Dim instance As WMIEventWatcher
public ref class WMIEventWatcher : public ManagementEventWatcher
type WMIEventWatcher =
class
inherit ManagementEventWatcher
end
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
Imports System.Management
Public NotInheritable Class Form1 : Inherits Form
Private WithEvents EventWatcher As New WMIEventWatcher("Win32_VolumeChangeEvent", withinInterval:=1)
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim connOptions As New ConnectionOptions With {
.Impersonation = ImpersonationLevel.Impersonate,
.EnablePrivileges = True
}
Dim scope As New ManagementScope(String.Format("\\{0}\ROOT\CIMV2", Environment.MachineName), connOptions)
scope.Connect()
Me.EventWatcher.Scope = scope
Me.EventWatcher.Start()
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As FormClosingEventArgs) Handles Me.FormClosing
Me.EventWatcher.Dispose()
End Sub
Private Sub EventWatcher_EventArrived(ByVal sender As Object, ByVal e As EventArrivedEventArgs) _
Handles EventWatcher.EventArrived
Dim driveName As String = CStr(e.NewEvent.Properties("DriveName").Value)
Dim eventType As Integer = CInt(e.NewEvent.Properties("EventType").Value)
Console.WriteLine(String.Format("Drive Name: {0}", driveName))
Console.WriteLine(String.Format("Event Type: {0}", eventType))
End Sub
End Class
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
WMIEventWatcher(SelectQuery) | Initializes a new instance of the WMIEventWatcher class. |
WMIEventWatcher(String) | Initializes a new instance of the WMIEventWatcher class. |
WMIEventWatcher(SelectQuery, Single) | Initializes a new instance of the WMIEventWatcher class. |
WMIEventWatcher(SelectQuery, TimeSpan) | Initializes a new instance of the WMIEventWatcher class. |
WMIEventWatcher(SelectQuery, UInt32) | Initializes a new instance of the WMIEventWatcher class. |
WMIEventWatcher(String, Single) | Initializes a new instance of the WMIEventWatcher class. |
WMIEventWatcher(String, TimeSpan) | Initializes a new instance of the WMIEventWatcher class. |
WMIEventWatcher(String, String, Single) | Initializes a new instance of the WMIEventWatcher class. |
WMIEventWatcher(String, String, TimeSpan) | Initializes a new instance of the WMIEventWatcher class. |
WMIEventWatcher(String, String, String, TimeSpan) | Initializes a new instance of the WMIEventWatcher class. |
WMIEventWatcher(String, String, String, UInt32) | Initializes a new instance of the WMIEventWatcher class. |
Container | Gets the IContainer that contains the Component. (Inherited from Component) |
Options | Gets or sets the options used to watch for events. (Inherited from ManagementEventWatcher) |
Query | Gets or sets the criteria to apply to events. (Inherited from ManagementEventWatcher) |
Scope | Gets or sets the scope in which to watch for events (namespace or scope). (Inherited from ManagementEventWatcher) |
Site | Gets or sets the ISite of the Component. (Inherited from Component) |
CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject) |
Dispose | Releases all resources used by the Component. (Inherited from Component) |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object) |
GetHashCode | Serves as the default hash function. (Inherited from Object) |
GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject) |
GetType | Gets the Type of the current instance. (Inherited from Object) |
InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject) |
Start | Subscribes to events with the given query and delivers them, asynchronously, through the EventArrived event. (Inherited from ManagementEventWatcher) |
Stop | Cancels the subscription whether it is synchronous or asynchronous. (Inherited from ManagementEventWatcher) |
ToString | Returns a String containing the name of the Component, if any. This method should not be overridden. (Inherited from Component) |
WaitForNextEvent | Waits for the next event that matches the specified query to arrive, and then returns it. (Inherited from ManagementEventWatcher) |
Disposed | Occurs when the component is disposed by a call to the Dispose method. (Inherited from Component) |
EventArrived | Occurs when a new event arrives. (Inherited from ManagementEventWatcher) |
Stopped | Occurs when a subscription is canceled. (Inherited from ManagementEventWatcher) |
CanConvertTo |
Determines whether the source object can be converted to the specified target type.
(Defined by ObjectExtensions) |
CanConvertToT |
Determines whether the source object can be converted to the specified target type.
(Defined by ObjectExtensions) |
ConvertToT |
Converts an object to the specified target type.
If the conversion fails, an exception is thrown.
(Defined by ObjectExtensions) |
ConvertToT |
Converts an object to the specified target type.
If the conversion fails, returns the specified default value.
(Defined by ObjectExtensions) |
GetEvent |
Gets a EventInfo that match the specified event name
declared in the source Component.
(Defined by ComponentExtensions) |
GetEventHandlers |
Gets all the delegates associated to the specified event raised by the source Component.
(Defined by ComponentExtensions) |
GetEvents |
Gets all the events declared in the source Component.
(Defined by ComponentExtensions) |
GetSubscribedEvents |
Gets a list of events declared in the source Component
that are subscribed to a event-handler.
(Defined by ComponentExtensions) |
InvokeUITypeEditorT |
Invokes the default UITypeEditor to edit the specified property.
(Defined by ComponentExtensions) |
InvokeUITypeEditorT |
Invokes the default UITypeEditor to edit the specified property.
(Defined by ComponentExtensions) |
IsDisposable |
Determines whether the specified object is a disposable type
(i.e., it implements IDisposable interface).
(Defined by ObjectExtensions) |
Speak |
Speaks the string representation of the source object by using the
operating system integrated text-to-speech synthesizer.
(Defined by ObjectExtensions) |
Speak |
Speaks the string representation of the source object by using the
operating system integrated text-to-speech synthesizer.
(Defined by ObjectExtensions) |
ThrowIfNullTException |
Throws the specified exception if the source object is null.
(Defined by ObjectExtensions) |
TryGetEvent |
Tries to get a EventInfo that match the specified event name
declared in the source Component.
(Defined by ComponentExtensions) |