InstrumentationType 枚举
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
指定由一个类提供的检测的类型。
注意:WMI .NET 库现在视为处于最终状态,且没有可用于会影响这些库的非安全性相关问题的进一步开发、增强或更新。 MI API 应用于所有新的开发。
public enum class InstrumentationType
public enum InstrumentationType
type InstrumentationType =
Public Enum InstrumentationType
- 继承
字段
Abstract | 2 | 该类定义管理检测的抽象类。 |
Event | 1 | 该类提供管理检测的事件。 |
Instance | 0 | 该类提供管理检测的实例。 |
示例
以下示例演示如何使用 InstrumentationType 枚举创建管理事件类。
using System;
using System.Management;
using System.Configuration.Install;
using System.Management.Instrumentation;
// This example demonstrates how to create
// a management event class by using
// the InstrumentationType enumeration
// Specify which namespace the management event
// class is created in
[assembly:Instrumented("Root/Default")]
// Let the system know you will run
// InstallUtil.exe tool against this assembly
[System.ComponentModel.RunInstaller(true)]
public class MyInstaller :
DefaultManagementProjectInstaller {}
namespace WMISample
{
// Create a management instrumentation event class
[InstrumentationClass(InstrumentationType.Event)]
public class MyEvent
{
private string EventName;
public void setEventName(string name)
{
EventName = name;
}
}
public class WMIInstrumentedEventExample
{
public static void Main()
{
MyEvent e = new MyEvent();
e.setEventName("Hello");
// Fire a management event
Instrumentation.Fire(e);
return;
}
}
}
Imports System.Management
Imports System.Configuration.Install
Imports System.Management.Instrumentation
' This sample demonstrates how to create
' a management event class by using
' the InstrumentationType enumeration
' Specify which namespace the management event
' class is created in
<Assembly: Instrumented("Root/Default")>
' Let the system know InstallUtil.exe tool will
' be run against this assembly
<System.ComponentModel.RunInstaller(True)> _
Public Class MyInstaller
Inherits DefaultManagementProjectInstaller
End Class
Namespace WMISample
' Create a management instrumentation event class
<InstrumentationClass(InstrumentationType.Event)> _
Public Class MyEvent
Private EventName As String
Function setEventName(ByVal name As String)
EventName = name
End Function
End Class
Public Class SampleEventProvider
Public Shared Function Main(ByVal args() _
As String) As Integer
Dim e As New MyEvent
e.setEventName("Hello")
' Fire a management event
System.Management.Instrumentation. _
Instrumentation.Fire(e)
Return 0
End Function
End Class
End Namespace