InstrumentationType 列舉

定義

指定類別提供的檢測型別。

注意:WMI .NET 程式庫目前被視為最終狀態,針對影響這些程式庫的非安全性相關問題,不會提供進一步的開發、增強功能或更新。 MI API 應使用於所有新的開發。

public enum class InstrumentationType
public enum InstrumentationType
type InstrumentationType = 
Public Enum InstrumentationType
繼承
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

適用於