ManagementClass Konstruktory

Definicja

Inicjuje nowe wystąpienie klasy ManagementClass.

Przeciążenia

ManagementClass()

Inicjuje nowe wystąpienie klasy ManagementClass. Jest to konstruktor bez parametrów.

ManagementClass(ManagementPath)

Inicjuje nowe wystąpienie klasy ManagementClass. Klasa reprezentuje klasę zarządzania Common Information Model (CIM) z usługi WMI, taką jak Win32_LogicalDisk, która może reprezentować dysk i Win32_Process, która reprezentuje proces, taki jak Notepad.exe.

ManagementClass(String)

Inicjuje ManagementClass nowe wystąpienie klasy zainicjowane do danej ścieżki. Klasa reprezentuje klasę zarządzania Common Information Model (CIM) z usługi WMI, taką jak Win32_LogicalDisk, która może reprezentować dysk i Win32_Process, która reprezentuje proces, taki jak Notepad.exe.

ManagementClass(ManagementPath, ObjectGetOptions)

Inicjuje ManagementClass nowe wystąpienie klasy zainicjowane do danej ścieżki klasy WMI przy użyciu określonych opcji. Klasa reprezentuje klasę zarządzania Common Information Model (CIM) z usługi WMI, taką jak Win32_LogicalDisk, która może reprezentować dysk i Win32_Process, która reprezentuje proces, taki jak Notepad.exe.

ManagementClass(SerializationInfo, StreamingContext)
Przestarzałe.

Inicjuje ManagementClass nowe wystąpienie klasy z określonych wystąpień SerializationInfo klas i StreamingContext .

ManagementClass(String, ObjectGetOptions)

Inicjuje ManagementClass nowe wystąpienie klasy zainicjowane do danej ścieżki klasy WMI przy użyciu określonych opcji. Klasa reprezentuje klasę zarządzania Common Information Model (CIM) z usługi WMI, taką jak Win32_LogicalDisk, która może reprezentować dysk i Win32_Process, która reprezentuje proces, taki jak Notepad.exe.

ManagementClass(ManagementScope, ManagementPath, ObjectGetOptions)

Inicjuje nowe wystąpienie ManagementClass klasy dla określonej klasy WMI w określonym zakresie i z określonymi opcjami. Klasa reprezentuje klasę zarządzania Common Information Model (CIM) z usługi WMI, taką jak Win32_LogicalDisk, która może reprezentować dysk i Win32_Process, która reprezentuje proces, taki jak Notepad.exe.

ManagementClass(String, String, ObjectGetOptions)

Inicjuje ManagementClass nowe wystąpienie klasy dla określonej klasy WMI w określonym zakresie i z określonymi opcjami. Klasa reprezentuje klasę zarządzania Common Information Model (CIM) z usługi WMI, taką jak Win32_LogicalDisk, która może reprezentować dysk i Win32_Process, która reprezentuje proces, taki jak Notepad.exe.

Uwagi

Zabezpieczenia.NET Framework

Pełne zaufanie do bezpośredniego wywołującego. Ten element członkowski nie może być używany przez kod częściowo zaufany. Aby uzyskać więcej informacji, zobacz Using Libraries from Partially Trusted Code (Używanie bibliotek z częściowo zaufanego kodu).

ManagementClass()

Źródło:
ManagementClass.cs
Źródło:
ManagementClass.cs
Źródło:
ManagementClass.cs

Inicjuje nowe wystąpienie klasy ManagementClass. Jest to konstruktor bez parametrów.

public:
 ManagementClass();
public ManagementClass ();
Public Sub New ()

Przykłady

Poniższy przykład to przykład inicjowania zmiennej ManagementClass za pomocą konstruktora bez parametrów ManagementClass . W przykładzie wymieniono metody, właściwości i kwalifikatory dla utworzonej klasy.

using System;
using System.Management;

public class Sample
{
    public static void Main()
    {

        // Get the WMI class
        ManagementClass processClass =
            new ManagementClass();
        processClass.Path = new
            ManagementPath("Win32_Process");

        // Get the methods in the class
        MethodDataCollection methods =
            processClass.Methods;

        // display the methods
        Console.WriteLine("Method Names: ");
        foreach (MethodData method in methods)
        {
            Console.WriteLine(method.Name);
        }
        Console.WriteLine();

        // Get the properties in the class
        PropertyDataCollection properties =
            processClass.Properties;

        // display the properties
        Console.WriteLine("Property Names: ");
        foreach (PropertyData property in properties)
        {
            Console.WriteLine(property.Name);
        }
        Console.WriteLine();

        // Get the Qualifiers in the class
        QualifierDataCollection qualifiers =
            processClass.Qualifiers;

        // display the qualifiers
        Console.WriteLine("Qualifier Names: ");
        foreach (QualifierData qualifier in qualifiers)
        {
            Console.WriteLine(qualifier.Name);
        }
    }
}
Imports System.Management


Class Sample
    Public Overloads Shared Function _
        Main(ByVal args() As String) As Integer

        ' Get the WMI class
        Dim processClass As New ManagementClass
        processClass.Path = New _
            ManagementPath("Win32_Process")

        ' Get the methods in the class
        Dim methods As MethodDataCollection
        methods = processClass.Methods

        ' display the methods
        Console.WriteLine("Method Names: ")
        For Each method As MethodData In methods

            Console.WriteLine(method.Name)
        Next
        Console.WriteLine()

        ' Get the properties in the class
        Dim properties As PropertyDataCollection
        properties = processClass.Properties

        ' display the properties
        Console.WriteLine("Property Names: ")
        For Each p As PropertyData In properties

            Console.WriteLine(p.Name)
        Next
        Console.WriteLine()

        ' Get the Qualifiers in the class
        Dim qualifiers As QualifierDataCollection = _
        processClass.Qualifiers()

        ' display the qualifiers
        Console.WriteLine("Qualifier Names: ")
        For Each qualifier As QualifierData In qualifiers

            Console.WriteLine(qualifier.Name)
        Next

    End Function
End Class

Uwagi

Zabezpieczenia.NET Framework

Pełne zaufanie do bezpośredniego wywołującego. Ten element członkowski nie może być używany przez kod częściowo zaufany. Aby uzyskać więcej informacji, zobacz Using Libraries from Partially Trusted Code (Używanie bibliotek z częściowo zaufanego kodu).

Dotyczy

ManagementClass(ManagementPath)

Źródło:
ManagementClass.cs
Źródło:
ManagementClass.cs
Źródło:
ManagementClass.cs

Inicjuje nowe wystąpienie klasy ManagementClass. Klasa reprezentuje klasę zarządzania Common Information Model (CIM) z usługi WMI, taką jak Win32_LogicalDisk, która może reprezentować dysk i Win32_Process, która reprezentuje proces, taki jak Notepad.exe.

public:
 ManagementClass(System::Management::ManagementPath ^ path);
public ManagementClass (System.Management.ManagementPath path);
new System.Management.ManagementClass : System.Management.ManagementPath -> System.Management.ManagementClass
Public Sub New (path As ManagementPath)

Parametry

path
ManagementPath

Określenie ManagementPath klasy WMI, do której ma być powiązane. Parametr musi określać ścieżkę klasy WMI. Klasa reprezentuje klasę zarządzania CIM z usługi WMI. Klasy ciM reprezentują informacje o zarządzaniu, w tym sprzęt, oprogramowanie, procesy itd. Aby uzyskać więcej informacji na temat klas CIM dostępnych w systemie Windows, zobacz Klasy modelu CIM.

Przykłady

Poniższy przykład to przykład inicjowania zmiennej ManagementClass za pomocą konstruktora ManagementClass . W przykładzie wymieniono metody, właściwości i kwalifikatory dla utworzonej klasy.

using System;
using System.Management;

public class Sample
{
    public static void Main()
    {

        // Get the WMI class
        ManagementClass c = new ManagementClass(
            new ManagementPath("Win32_LogicalDisk"));

        // Get the methods in the class
        MethodDataCollection methods =
            c.Methods;

        // display the methods
        Console.WriteLine("Method Names: ");
        foreach (MethodData method in methods)
        {
            Console.WriteLine(method.Name);
        }
        Console.WriteLine();

        // Get the properties in the class
        PropertyDataCollection properties =
            c.Properties;

        // display the properties
        Console.WriteLine("Property Names: ");
        foreach (PropertyData property in properties)
        {
            Console.WriteLine(property.Name);
        }
        Console.WriteLine();

        // Get the Qualifiers in the class
        QualifierDataCollection qualifiers =
            c.Qualifiers;

        // display the qualifiers
        Console.WriteLine("Qualifier Names: ");
        foreach (QualifierData qualifier in qualifiers)
        {
            Console.WriteLine(qualifier.Name);
        }
    }
}
Imports System.Management


Class Sample
    Public Overloads Shared Function _
        Main(ByVal args() As String) As Integer

        ' Get the WMI class
        Dim c As New ManagementClass( _
            New ManagementPath("Win32_LogicalDisk"))


        ' Get the methods in the class
        Dim methods As MethodDataCollection
        methods = c.Methods

        ' display the methods
        Console.WriteLine("Method Names: ")
        For Each method As MethodData In methods

            Console.WriteLine(method.Name)
        Next
        Console.WriteLine()

        ' Get the properties in the class
        Dim properties As PropertyDataCollection
        properties = c.Properties

        ' display the properties
        Console.WriteLine("Property Names: ")
        For Each p As PropertyData In properties

            Console.WriteLine(p.Name)
        Next
        Console.WriteLine()

        ' Get the Qualifiers in the class
        Dim qualifiers As QualifierDataCollection = _
        c.Qualifiers()

        ' display the qualifiers
        Console.WriteLine("Qualifier Names: ")
        For Each qualifier As QualifierData In qualifiers

            Console.WriteLine(qualifier.Name)
        Next

    End Function
End Class

Uwagi

Parametr path musi określać ścieżkę klasy WMI.

Zabezpieczenia.NET Framework

Pełne zaufanie do bezpośredniego wywołującego. Ten element członkowski nie może być używany przez kod częściowo zaufany. Aby uzyskać więcej informacji, zobacz Using Libraries from Partially Trusted Code (Używanie bibliotek z częściowo zaufanego kodu).

Dotyczy

ManagementClass(String)

Źródło:
ManagementClass.cs
Źródło:
ManagementClass.cs
Źródło:
ManagementClass.cs

Inicjuje ManagementClass nowe wystąpienie klasy zainicjowane do danej ścieżki. Klasa reprezentuje klasę zarządzania Common Information Model (CIM) z usługi WMI, taką jak Win32_LogicalDisk, która może reprezentować dysk i Win32_Process, która reprezentuje proces, taki jak Notepad.exe.

public:
 ManagementClass(System::String ^ path);
public ManagementClass (string path);
new System.Management.ManagementClass : string -> System.Management.ManagementClass
Public Sub New (path As String)

Parametry

path
String

Ścieżka do klasy WMI. Klasa reprezentuje klasę zarządzania CIM z usługi WMI. Klasy ciM reprezentują informacje o zarządzaniu, w tym sprzęt, oprogramowanie, procesy itd. Aby uzyskać więcej informacji na temat klas CIM dostępnych w systemie Windows, zobacz Klasy modelu CIM.

Przykłady

W poniższym przykładzie pokazano, jak zainicjować zmienną ManagementClass za pomocą konstruktora ManagementClass . W przykładzie wymieniono metody, właściwości i kwalifikatory dla utworzonej klasy.

using System;
using System.Management;

public class Sample
{
    public static void Main()
    {

        // Get the WMI class
        ManagementClass c =
            new ManagementClass("Win32_LogicalDisk");

        // Get the methods in the class
        MethodDataCollection methods =
            c.Methods;

        // display the methods
        Console.WriteLine("Method Names: ");
        foreach (MethodData method in methods)
        {
            Console.WriteLine(method.Name);
        }
        Console.WriteLine();

        // Get the properties in the class
        PropertyDataCollection properties =
            c.Properties;

        // display the properties
        Console.WriteLine("Property Names: ");
        foreach (PropertyData property in properties)
        {
            Console.WriteLine(property.Name);
        }
        Console.WriteLine();

        // Get the Qualifiers in the class
        QualifierDataCollection qualifiers =
            c.Qualifiers;

        // display the qualifiers
        Console.WriteLine("Qualifier Names: ");
        foreach (QualifierData qualifier in qualifiers)
        {
            Console.WriteLine(qualifier.Name);
        }
    }
}
Imports System.Management


Class Sample
    Public Overloads Shared Function _
        Main(ByVal args() As String) As Integer

        ' Get the WMI class
        Dim c As New ManagementClass("Win32_LogicalDisk")

        ' Get the methods in the class
        Dim methods As MethodDataCollection
        methods = c.Methods

        ' display the methods
        Console.WriteLine("Method Names: ")
        For Each method As MethodData In methods

            Console.WriteLine(method.Name)
        Next
        Console.WriteLine()

        ' Get the properties in the class
        Dim properties As PropertyDataCollection
        properties = c.Properties

        ' display the properties
        Console.WriteLine("Property Names: ")
        For Each p As PropertyData In properties

            Console.WriteLine(p.Name)
        Next
        Console.WriteLine()

        ' Get the Qualifiers in the class
        Dim qualifiers As QualifierDataCollection = _
        c.Qualifiers()

        ' display the qualifiers
        Console.WriteLine("Qualifier Names: ")
        For Each qualifier As QualifierData In qualifiers

            Console.WriteLine(qualifier.Name)
        Next

    End Function
End Class

Uwagi

Zabezpieczenia.NET Framework

Pełne zaufanie do bezpośredniego wywołującego. Ten element członkowski nie może być używany przez kod częściowo zaufany. Aby uzyskać więcej informacji, zobacz Using Libraries from Partially Trusted Code (Używanie bibliotek z częściowo zaufanego kodu).

Dotyczy

ManagementClass(ManagementPath, ObjectGetOptions)

Źródło:
ManagementClass.cs
Źródło:
ManagementClass.cs
Źródło:
ManagementClass.cs

Inicjuje ManagementClass nowe wystąpienie klasy zainicjowane do danej ścieżki klasy WMI przy użyciu określonych opcji. Klasa reprezentuje klasę zarządzania Common Information Model (CIM) z usługi WMI, taką jak Win32_LogicalDisk, która może reprezentować dysk i Win32_Process, która reprezentuje proces, taki jak Notepad.exe.

public:
 ManagementClass(System::Management::ManagementPath ^ path, System::Management::ObjectGetOptions ^ options);
public ManagementClass (System.Management.ManagementPath path, System.Management.ObjectGetOptions options);
new System.Management.ManagementClass : System.Management.ManagementPath * System.Management.ObjectGetOptions -> System.Management.ManagementClass
Public Sub New (path As ManagementPath, options As ObjectGetOptions)

Parametry

path
ManagementPath

ManagementPath Wystąpienie reprezentujące ścieżkę klasy WMI. Klasa reprezentuje klasę zarządzania CIM z usługi WMI. Klasy ciM reprezentują informacje o zarządzaniu, w tym sprzęt, oprogramowanie, procesy itd. Aby uzyskać więcej informacji na temat klas CIM dostępnych w systemie Windows, zobacz Klasy modelu CIM.

options
ObjectGetOptions

Reprezentująca ObjectGetOptions opcje do użycia podczas pobierania tej klasy.

Przykłady

Poniższy przykład to przykład inicjowania zmiennej ManagementClass za pomocą konstruktora ManagementClass . W przykładzie wymieniono metody, właściwości i kwalifikatory (w tym zmienione kwalifikatory) dla utworzonej klasy.

using System;
using System.Management;

public class Sample
{
    public static void Main()
    {

        // Get the WMI class
        ManagementPath p =
            new ManagementPath("Win32_Process");
        // Options specify that amended qualifiers
        // are to be retrieved along with the class
        ObjectGetOptions o = new ObjectGetOptions(
            null, System.TimeSpan.MaxValue, true);
        ManagementClass c = new ManagementClass(p,o);

        // Get the methods in the class
        MethodDataCollection methods =
            c.Methods;

        // display the methods
        Console.WriteLine("Method Names: ");
        foreach (MethodData method in methods)
        {
            Console.WriteLine(method.Name);
        }
        Console.WriteLine();

        // Get the properties in the class
        PropertyDataCollection properties =
            c.Properties;

        // display the properties
        Console.WriteLine("Property Names: ");
        foreach (PropertyData property in properties)
        {
            Console.WriteLine(property.Name);
        }
        Console.WriteLine();

        // Get the Qualifiers in the class
        QualifierDataCollection qualifiers =
            c.Qualifiers;

        // display the qualifiers
        Console.WriteLine("Qualifier Names: ");
        foreach (QualifierData qualifier in qualifiers)
        {
            Console.WriteLine(qualifier.Name);
        }
    }
}
Imports System.Management


Class Sample
    Public Overloads Shared Function _
        Main(ByVal args() As String) As Integer

        ' Get the WMI class
        Dim p As New ManagementPath("Win32_Process")
        ' Options specify that amended qualifiers
        ' are to be retrieved along with the class
        Dim o As New ObjectGetOptions( _
            Nothing, System.TimeSpan.MaxValue, True)
        Dim c As New ManagementClass(p, o)

        ' Get the methods in the class
        Dim methods As MethodDataCollection
        methods = c.Methods

        ' display the methods
        Console.WriteLine("Method Names: ")
        For Each method As MethodData In methods

            Console.WriteLine(method.Name)
        Next
        Console.WriteLine()

        ' Get the properties in the class
        Dim properties As PropertyDataCollection
        properties = c.Properties

        ' display the properties
        Console.WriteLine("Property Names: ")
        For Each pdata As PropertyData In properties

            Console.WriteLine(pdata.Name)
        Next
        Console.WriteLine()

        ' Get the Qualifiers in the class
        Dim qualifiers As QualifierDataCollection = _
        c.Qualifiers()

        ' display the qualifiers
        Console.WriteLine("Qualifier Names: ")
        For Each qualifier As QualifierData In qualifiers

            Console.WriteLine(qualifier.Name)
        Next

    End Function
End Class

Uwagi

Zabezpieczenia.NET Framework

Pełne zaufanie do bezpośredniego wywołującego. Ten element członkowski nie może być używany przez kod częściowo zaufany. Aby uzyskać więcej informacji, zobacz Using Libraries from Partially Trusted Code (Używanie bibliotek z częściowo zaufanego kodu).

Dotyczy

ManagementClass(SerializationInfo, StreamingContext)

Źródło:
ManagementClass.cs
Źródło:
ManagementClass.cs
Źródło:
ManagementClass.cs

Przestroga

This API supports obsolete formatter-based serialization. It should not be called or extended by application code.

Inicjuje ManagementClass nowe wystąpienie klasy z określonych wystąpień SerializationInfo klas i StreamingContext .

protected:
 ManagementClass(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected ManagementClass (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
[System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
protected ManagementClass (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new System.Management.ManagementClass : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Management.ManagementClass
[<System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Management.ManagementClass : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Management.ManagementClass
Protected Sub New (info As SerializationInfo, context As StreamingContext)

Parametry

info
SerializationInfo

Wystąpienie SerializationInfo klasy zawierające informacje wymagane do serializacji nowego ManagementClasselementu .

context
StreamingContext

Wystąpienie StreamingContext klasy zawierające źródło serializowanego strumienia skojarzonego z nowym ManagementClass.

Atrybuty

Uwagi

Zabezpieczenia.NET Framework

Pełne zaufanie do bezpośredniego wywołującego. Ten element członkowski nie może być używany przez kod częściowo zaufany. Aby uzyskać więcej informacji, zobacz Using Libraries from Partially Trusted Code (Używanie bibliotek z częściowo zaufanego kodu).

Dotyczy

ManagementClass(String, ObjectGetOptions)

Źródło:
ManagementClass.cs
Źródło:
ManagementClass.cs
Źródło:
ManagementClass.cs

Inicjuje ManagementClass nowe wystąpienie klasy zainicjowane do danej ścieżki klasy WMI przy użyciu określonych opcji. Klasa reprezentuje klasę zarządzania Common Information Model (CIM) z usługi WMI, taką jak Win32_LogicalDisk, która może reprezentować dysk i Win32_Process, która reprezentuje proces, taki jak Notepad.exe.

public:
 ManagementClass(System::String ^ path, System::Management::ObjectGetOptions ^ options);
public ManagementClass (string path, System.Management.ObjectGetOptions options);
new System.Management.ManagementClass : string * System.Management.ObjectGetOptions -> System.Management.ManagementClass
Public Sub New (path As String, options As ObjectGetOptions)

Parametry

path
String

Ścieżka do klasy WMI. Klasa reprezentuje klasę zarządzania CIM z usługi WMI. Klasy ciM reprezentują informacje o zarządzaniu, w tym sprzęt, oprogramowanie, procesy itd. Aby uzyskać więcej informacji na temat klas CIM dostępnych w systemie Windows, zobacz Klasy modelu CIM.

options
ObjectGetOptions

Reprezentująca ObjectGetOptions opcje do użycia podczas pobierania klasy WMI.

Przykłady

W poniższym przykładzie pokazano, jak zainicjować zmienną ManagementClass za pomocą konstruktora ManagementClass . W przykładzie wymieniono metody, właściwości i kwalifikatory (w tym zmienione kwalifikatory) dla utworzonej klasy.

using System;
using System.Management;

public class Sample
{
    public static void Main()
    {

        // Get the WMI class
        //Options specify that amended qualifiers
        // should be retrieved along with the class
        ObjectGetOptions o = new ObjectGetOptions(
            null, System.TimeSpan.MaxValue, true);
        ManagementClass c =
            new ManagementClass("Win32_ComputerSystem",o);

        // Get the methods in the class
        MethodDataCollection methods =
            c.Methods;

        // display the methods
        Console.WriteLine("Method Names: ");
        foreach (MethodData method in methods)
        {
            Console.WriteLine(method.Name);
        }
        Console.WriteLine();

        // Get the properties in the class
        PropertyDataCollection properties =
            c.Properties;

        // display the properties
        Console.WriteLine("Property Names: ");
        foreach (PropertyData property in properties)
        {
            Console.WriteLine(property.Name);
        }
        Console.WriteLine();

        // Get the Qualifiers in the class
        QualifierDataCollection qualifiers =
            c.Qualifiers;

        // display the qualifiers
        Console.WriteLine("Qualifier Names: ");
        foreach (QualifierData qualifier in qualifiers)
        {
            Console.WriteLine(qualifier.Name);
        }
    }
}
Imports System.Management

Class Sample
    Public Overloads Shared Function _
        Main(ByVal args() As String) As Integer

        ' Get the WMI class
        ' Options specify that amended qualifiers
        ' should be retrieved along with the class
        Dim o As New ObjectGetOptions( _
            Nothing, System.TimeSpan.MaxValue, True)
        Dim c As New ManagementClass("Win32_ComputerSystem", o)

        ' Get the methods in the class
        Dim methods As MethodDataCollection
        methods = c.Methods

        ' display the methods
        Console.WriteLine("Method Names: ")
        For Each method As MethodData In methods

            Console.WriteLine(method.Name)
        Next
        Console.WriteLine()

        ' Get the properties in the class
        Dim properties As PropertyDataCollection
        properties = c.Properties

        ' display the properties
        Console.WriteLine("Property Names: ")
        For Each p As PropertyData In properties

            Console.WriteLine(p.Name)
        Next
        Console.WriteLine()

        ' Get the Qualifiers in the class
        Dim qualifiers As QualifierDataCollection = _
        c.Qualifiers()

        ' display the qualifiers
        Console.WriteLine("Qualifier Names: ")
        For Each qualifier As QualifierData In qualifiers

            Console.WriteLine(qualifier.Name)
        Next

    End Function
End Class

Uwagi

Zabezpieczenia.NET Framework

Pełne zaufanie do bezpośredniego wywołującego. Ten element członkowski nie może być używany przez kod częściowo zaufany. Aby uzyskać więcej informacji, zobacz Using Libraries from Partially Trusted Code (Używanie bibliotek z częściowo zaufanego kodu).

Dotyczy

ManagementClass(ManagementScope, ManagementPath, ObjectGetOptions)

Źródło:
ManagementClass.cs
Źródło:
ManagementClass.cs
Źródło:
ManagementClass.cs

Inicjuje nowe wystąpienie ManagementClass klasy dla określonej klasy WMI w określonym zakresie i z określonymi opcjami. Klasa reprezentuje klasę zarządzania Common Information Model (CIM) z usługi WMI, taką jak Win32_LogicalDisk, która może reprezentować dysk i Win32_Process, która reprezentuje proces, taki jak Notepad.exe.

public:
 ManagementClass(System::Management::ManagementScope ^ scope, System::Management::ManagementPath ^ path, System::Management::ObjectGetOptions ^ options);
public ManagementClass (System.Management.ManagementScope scope, System.Management.ManagementPath path, System.Management.ObjectGetOptions options);
new System.Management.ManagementClass : System.Management.ManagementScope * System.Management.ManagementPath * System.Management.ObjectGetOptions -> System.Management.ManagementClass
Public Sub New (scope As ManagementScope, path As ManagementPath, options As ObjectGetOptions)

Parametry

scope
ManagementScope

Element ManagementScope określający zakres (serwer i przestrzeń nazw), w którym znajduje się klasa WMI.

path
ManagementPath

Element ManagementPath reprezentujący ścieżkę do klasy WMI w określonym zakresie. Klasa reprezentuje klasę zarządzania CIM z usługi WMI. Klasy ciM reprezentują informacje o zarządzaniu, w tym sprzęt, oprogramowanie, procesy itd. Aby uzyskać więcej informacji na temat klas CIM dostępnych w systemie Windows, zobacz Klasy modelu CIM.

options
ObjectGetOptions

Element ObjectGetOptions określający opcje do użycia podczas pobierania klasy WMI.

Przykłady

Poniższy przykład to przykład inicjowania zmiennej ManagementClass za pomocą konstruktora ManagementClass . W przykładzie wymieniono metody, właściwości i kwalifikatory (w tym zmienione kwalifikatory) dla utworzonej klasy. Musisz zmienić zakres (przestrzeń nazw) w kodzie, aby przykład działał poprawnie na komputerze.

using System;
using System.Management;

public class Sample
{
    public static void Main()
    {

        // Get the WMI class
        ManagementScope s =
            new ManagementScope("\\\\MyBox\\root\\cimv2");
        ManagementPath p = new ManagementPath("Win32_Environment");
        ObjectGetOptions o = new ObjectGetOptions(
            null, System.TimeSpan.MaxValue, true);
        ManagementClass c = new ManagementClass(s, p, o);

        // Get the methods in the class
        MethodDataCollection methods =
            c.Methods;

        // display the methods
        Console.WriteLine("Method Names: ");
        foreach (MethodData method in methods)
        {
            Console.WriteLine(method.Name);
        }
        Console.WriteLine();

        // Get the properties in the class
        PropertyDataCollection properties =
            c.Properties;

        // display the properties
        Console.WriteLine("Property Names: ");
        foreach (PropertyData property in properties)
        {
            Console.WriteLine(property.Name);
        }
        Console.WriteLine();

        // Get the Qualifiers in the class
        QualifierDataCollection qualifiers =
            c.Qualifiers;

        // display the qualifiers
        Console.WriteLine("Qualifier Names: ");
        foreach (QualifierData qualifier in qualifiers)
        {
            Console.WriteLine(qualifier.Name);
        }
    }
}
Imports System.Management

Class Sample
    Public Overloads Shared Function _
        Main(ByVal args() As String) As Integer

        ' Get the WMI class
        Dim s As New ManagementScope("\\MyBox\root\cimv2")
        Dim p As New ManagementPath("Win32_Environment")
        Dim o As New ObjectGetOptions( _
            Nothing, System.TimeSpan.MaxValue, True)
        Dim c As New ManagementClass(s, p, o)

        ' Get the methods in the class
        Dim methods As MethodDataCollection
        methods = c.Methods

        ' display the methods
        Console.WriteLine("Method Names: ")
        For Each method As MethodData In methods

            Console.WriteLine(method.Name)
        Next
        Console.WriteLine()

        ' Get the properties in the class
        Dim properties As PropertyDataCollection
        properties = c.Properties

        ' display the properties
        Console.WriteLine("Property Names: ")
        Dim data As PropertyData
        For Each data In properties

            Console.WriteLine(data.Name)
        Next
        Console.WriteLine()

        ' Get the Qualifiers in the class
        Dim qualifiers As QualifierDataCollection = _
        c.Qualifiers()

        ' display the qualifiers
        Console.WriteLine("Qualifier Names: ")
        For Each qualifier As QualifierData In qualifiers

            Console.WriteLine(qualifier.Name)
        Next

    End Function
End Class

Uwagi

Ścieżkę można określić jako pełną ścieżkę (w tym serwer i przestrzeń nazw). Jeśli jednak zostanie określony zakres, zastąpi pierwszą część pełnej ścieżki.

Zabezpieczenia.NET Framework

Pełne zaufanie do bezpośredniego wywołującego. Ten element członkowski nie może być używany przez kod częściowo zaufany. Aby uzyskać więcej informacji, zobacz Using Libraries from Partially Trusted Code (Używanie bibliotek z częściowo zaufanego kodu).

Dotyczy

ManagementClass(String, String, ObjectGetOptions)

Źródło:
ManagementClass.cs
Źródło:
ManagementClass.cs
Źródło:
ManagementClass.cs

Inicjuje ManagementClass nowe wystąpienie klasy dla określonej klasy WMI w określonym zakresie i z określonymi opcjami. Klasa reprezentuje klasę zarządzania Common Information Model (CIM) z usługi WMI, taką jak Win32_LogicalDisk, która może reprezentować dysk i Win32_Process, która reprezentuje proces, taki jak Notepad.exe.

public:
 ManagementClass(System::String ^ scope, System::String ^ path, System::Management::ObjectGetOptions ^ options);
public ManagementClass (string scope, string path, System.Management.ObjectGetOptions options);
new System.Management.ManagementClass : string * string * System.Management.ObjectGetOptions -> System.Management.ManagementClass
Public Sub New (scope As String, path As String, options As ObjectGetOptions)

Parametry

scope
String

Zakres, w którym znajduje się klasa WMI.

path
String

Ścieżka do klasy WMI w określonym zakresie. Klasa reprezentuje klasę zarządzania CIM z usługi WMI. Klasy ciM reprezentują informacje o zarządzaniu, w tym sprzęt, oprogramowanie, procesy itd. Aby uzyskać więcej informacji na temat klas CIM dostępnych w systemie Windows, zobacz Klasy modelu CIM.

options
ObjectGetOptions

Element ObjectGetOptions określający opcje do użycia podczas pobierania klasy WMI.

Przykłady

W poniższym przykładzie pokazano, jak zainicjować zmienną ManagementClass za pomocą konstruktora ManagementClass . W przykładzie wymieniono metody, właściwości i kwalifikatory (w tym zmienione kwalifikatory) dla utworzonej klasy. Musisz zmienić zakres (przestrzeń nazw) w kodzie, aby przykład działał poprawnie na komputerze.

using System;
using System.Management;

public class Sample
{
    public static void Main()
    {

        // Get the WMI class
        //Options specify that amended qualifiers
        // should be retrieved along with the class
        ManagementClass c =
            new ManagementClass("\\\\MyBox\\root\\cimv2",
            "Win32_Environment",
            new ObjectGetOptions(
            null, System.TimeSpan.MaxValue, true));

        // Get the methods in the class
        MethodDataCollection methods =
            c.Methods;

        // display the methods
        Console.WriteLine("Method Names: ");
        foreach (MethodData method in methods)
        {
            Console.WriteLine(method.Name);
        }
        Console.WriteLine();

        // Get the properties in the class
        PropertyDataCollection properties =
            c.Properties;

        // display the properties
        Console.WriteLine("Property Names: ");
        foreach (PropertyData property in properties)
        {
            Console.WriteLine(property.Name);
        }
        Console.WriteLine();

        // Get the Qualifiers in the class
        QualifierDataCollection qualifiers =
            c.Qualifiers;

        // display the qualifiers
        Console.WriteLine("Qualifier Names: ");
        foreach (QualifierData qualifier in qualifiers)
        {
            Console.WriteLine(qualifier.Name);
        }
    }
}
Imports System.Management


Class Sample
    Public Overloads Shared Function _
        Main(ByVal args() As String) As Integer

        ' Get the WMI class
        ' Options specify that amended qualifiers
        ' should be retrieved along with the class
        Dim c As New ManagementClass("\\MyBox\root\cimv2", _
            "Win32_Environment", _
            New ObjectGetOptions( _
            Nothing, System.TimeSpan.MaxValue, True))


        ' Get the methods in the class
        Dim methods As MethodDataCollection
        methods = c.Methods

        ' display the methods
        Console.WriteLine("Method Names: ")
        For Each method As MethodData In methods

            Console.WriteLine(method.Name)
        Next
        Console.WriteLine()

        ' Get the properties in the class
        Dim properties As PropertyDataCollection
        properties = c.Properties

        ' display the properties
        Console.WriteLine("Property Names: ")
        For Each p As PropertyData In properties

            Console.WriteLine(p.Name)
        Next
        Console.WriteLine()

        ' Get the Qualifiers in the class
        Dim qualifiers As QualifierDataCollection = _
        c.Qualifiers()

        ' display the qualifiers
        Console.WriteLine("Qualifier Names: ")
        For Each qualifier As QualifierData In qualifiers

            Console.WriteLine(qualifier.Name)
        Next

    End Function
End Class

Uwagi

Ścieżkę można określić jako pełną ścieżkę (w tym serwer i przestrzeń nazw). Jeśli jednak zostanie określony zakres, zastąpi pierwszą część pełnej ścieżki.

Zabezpieczenia.NET Framework

Pełne zaufanie do bezpośredniego wywołującego. Ten element członkowski nie może być używany przez kod częściowo zaufany. Aby uzyskać więcej informacji, zobacz Using Libraries from Partially Trusted Code (Używanie bibliotek z częściowo zaufanego kodu).

Dotyczy