ManagementClass Konstruktory
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Inicializuje novou instanci ManagementClass třídy.
Přetížení
| Name | Description |
|---|---|
| ManagementClass() |
Inicializuje novou instanci ManagementClass třídy. Toto je konstruktor bez parametrů. |
| ManagementClass(ManagementPath) |
Inicializuje novou instanci ManagementClass třídy. Třída představuje třídu správy modelu CIM (Common Information Model) ze služby WMI, jako je Win32_LogicalDisk, která může představovat diskovou jednotku a Win32_Process, která představuje proces, jako je Notepad.exe. |
| ManagementClass(String) |
Inicializuje novou instanci ManagementClass třídy inicializované na danou cestu. Třída představuje třídu správy modelu CIM (Common Information Model) ze služby WMI, jako je Win32_LogicalDisk, která může představovat diskovou jednotku a Win32_Process, která představuje proces, jako je Notepad.exe. |
| ManagementClass(ManagementPath, ObjectGetOptions) |
Inicializuje novou instanci ManagementClass třídy inicializované na danou cestu třídy WMI pomocí zadaných možností. Třída představuje třídu správy modelu CIM (Common Information Model) ze služby WMI, jako je Win32_LogicalDisk, která může představovat diskovou jednotku a Win32_Process, která představuje proces, jako je Notepad.exe. |
| ManagementClass(SerializationInfo, StreamingContext) |
Zastaralé.
Inicializuje novou instanci ManagementClass třídy ze zadaných SerializationInfo instancí třídy a StreamingContext třídy. |
| ManagementClass(String, ObjectGetOptions) |
Inicializuje novou instanci ManagementClass třídy inicializované na danou cestu třídy WMI pomocí zadaných možností. Třída představuje třídu správy modelu CIM (Common Information Model) ze služby WMI, jako je Win32_LogicalDisk, která může představovat diskovou jednotku a Win32_Process, která představuje proces, jako je Notepad.exe. |
| ManagementClass(ManagementScope, ManagementPath, ObjectGetOptions) |
Inicializuje novou instanci ManagementClass třídy pro zadanou třídu WMI v zadaném oboru a se zadanými možnostmi. Třída představuje třídu správy modelu CIM (Common Information Model) ze služby WMI, jako je Win32_LogicalDisk, která může představovat diskovou jednotku a Win32_Process, která představuje proces, jako je Notepad.exe. |
| ManagementClass(String, String, ObjectGetOptions) |
Inicializuje novou instanci ManagementClass třídy pro zadanou třídu WMI v zadaném oboru a se zadanými možnostmi. Třída představuje třídu správy modelu CIM (Common Information Model) ze služby WMI, jako je Win32_LogicalDisk, která může představovat diskovou jednotku a Win32_Process, která představuje proces, jako je Notepad.exe. |
Poznámky
Zabezpečení rozhraní .NET Framework
Plný vztah důvěryhodnosti pro okamžitého volajícího. Tento člen nemůže být používán částečně důvěryhodným kódem. Další informace naleznete v tématu Použití knihoven z částečně důvěryhodného kódu.
ManagementClass()
- Zdroj:
- ManagementClass.cs
- Zdroj:
- ManagementClass.cs
- Zdroj:
- ManagementClass.cs
- Zdroj:
- ManagementClass.cs
Inicializuje novou instanci ManagementClass třídy. Toto je konstruktor bez parametrů.
public:
ManagementClass();
public ManagementClass();
Public Sub New ()
Příklady
Následující příklad je příkladem inicializace ManagementClass proměnné pomocí konstruktoru ManagementClass bez parametrů. V příkladu jsou uvedeny metody, vlastnosti a kvalifikátory pro vytvořenou třídu.
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
Poznámky
Zabezpečení rozhraní .NET Framework
Plný vztah důvěryhodnosti pro okamžitého volajícího. Tento člen nemůže být používán částečně důvěryhodným kódem. Další informace naleznete v tématu Použití knihoven z částečně důvěryhodného kódu.
Platí pro
ManagementClass(ManagementPath)
- Zdroj:
- ManagementClass.cs
- Zdroj:
- ManagementClass.cs
- Zdroj:
- ManagementClass.cs
- Zdroj:
- ManagementClass.cs
Inicializuje novou instanci ManagementClass třídy. Třída představuje třídu správy modelu CIM (Common Information Model) ze služby WMI, jako je Win32_LogicalDisk, která může představovat diskovou jednotku a Win32_Process, která představuje proces, jako je 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
Určuje ManagementPath třídu rozhraní WMI, ke které se má svázat. Parametr musí zadat cestu třídy WMI. Třída představuje třídu správy CIM ze služby WMI. Třídy CIM představují informace o správě, včetně hardwaru, softwaru, procesů atd. Další informace o třídách CIM dostupných v Windows naleznete v tématu CIM Classes.
Příklady
Následující příklad je příkladem, jak inicializovat ManagementClass proměnnou pomocí konstruktoru ManagementClass . V příkladu jsou uvedeny metody, vlastnosti a kvalifikátory pro vytvořenou třídu.
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
Poznámky
Parametr path musí zadat cestu třídy WMI.
Zabezpečení rozhraní .NET Framework
Plný vztah důvěryhodnosti pro okamžitého volajícího. Tento člen nemůže být používán částečně důvěryhodným kódem. Další informace naleznete v tématu Použití knihoven z částečně důvěryhodného kódu.
Platí pro
ManagementClass(String)
- Zdroj:
- ManagementClass.cs
- Zdroj:
- ManagementClass.cs
- Zdroj:
- ManagementClass.cs
- Zdroj:
- ManagementClass.cs
Inicializuje novou instanci ManagementClass třídy inicializované na danou cestu. Třída představuje třídu správy modelu CIM (Common Information Model) ze služby WMI, jako je Win32_LogicalDisk, která může představovat diskovou jednotku a Win32_Process, která představuje proces, jako je 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
Cesta ke třídě služby WMI. Třída představuje třídu správy CIM ze služby WMI. Třídy CIM představují informace o správě, včetně hardwaru, softwaru, procesů atd. Další informace o třídách CIM dostupných v Windows naleznete v tématu CIM Classes.
Příklady
Následující příklad ukazuje, jak inicializovat proměnnou ManagementClass pomocí konstruktoru ManagementClass . V příkladu jsou uvedeny metody, vlastnosti a kvalifikátory pro vytvořenou třídu.
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
Poznámky
Zabezpečení rozhraní .NET Framework
Plný vztah důvěryhodnosti pro okamžitého volajícího. Tento člen nemůže být používán částečně důvěryhodným kódem. Další informace naleznete v tématu Použití knihoven z částečně důvěryhodného kódu.
Platí pro
ManagementClass(ManagementPath, ObjectGetOptions)
- Zdroj:
- ManagementClass.cs
- Zdroj:
- ManagementClass.cs
- Zdroj:
- ManagementClass.cs
- Zdroj:
- ManagementClass.cs
Inicializuje novou instanci ManagementClass třídy inicializované na danou cestu třídy WMI pomocí zadaných možností. Třída představuje třídu správy modelu CIM (Common Information Model) ze služby WMI, jako je Win32_LogicalDisk, která může představovat diskovou jednotku a Win32_Process, která představuje proces, jako je 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
Instance ManagementPath představující cestu třídy WMI. Třída představuje třídu správy CIM ze služby WMI. Třídy CIM představují informace o správě, včetně hardwaru, softwaru, procesů atd. Další informace o třídách CIM dostupných v Windows naleznete v tématu CIM Classes.
- options
- ObjectGetOptions
Představuje ObjectGetOptions možnosti, které se mají použít při načítání této třídy.
Příklady
Následující příklad je příkladem, jak inicializovat ManagementClass proměnnou pomocí konstruktoru ManagementClass . V příkladu jsou uvedeny metody, vlastnosti a kvalifikátory (včetně upravených kvalifikátorů) pro vytvořenou třídu.
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
Poznámky
Zabezpečení rozhraní .NET Framework
Plný vztah důvěryhodnosti pro okamžitého volajícího. Tento člen nemůže být používán částečně důvěryhodným kódem. Další informace naleznete v tématu Použití knihoven z částečně důvěryhodného kódu.
Platí pro
ManagementClass(SerializationInfo, StreamingContext)
- Zdroj:
- ManagementClass.cs
- Zdroj:
- ManagementClass.cs
- Zdroj:
- ManagementClass.cs
- Zdroj:
- ManagementClass.cs
Upozornění
This API supports obsolete formatter-based serialization. It should not be called or extended by application code.
Inicializuje novou instanci ManagementClass třídy ze zadaných SerializationInfo instancí třídy a StreamingContext třídy.
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);
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}")>]
new System.Management.ManagementClass : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Management.ManagementClass
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
Instance SerializationInfo třídy obsahující informace potřebné k serializaci nové ManagementClass.
- context
- StreamingContext
Instance StreamingContext třídy obsahující zdroj serializovaného datového proudu asociovaného s novým ManagementClass.
- Atributy
Poznámky
Zabezpečení rozhraní .NET Framework
Plný vztah důvěryhodnosti pro okamžitého volajícího. Tento člen nemůže být používán částečně důvěryhodným kódem. Další informace naleznete v tématu Použití knihoven z částečně důvěryhodného kódu.
Platí pro
ManagementClass(String, ObjectGetOptions)
- Zdroj:
- ManagementClass.cs
- Zdroj:
- ManagementClass.cs
- Zdroj:
- ManagementClass.cs
- Zdroj:
- ManagementClass.cs
Inicializuje novou instanci ManagementClass třídy inicializované na danou cestu třídy WMI pomocí zadaných možností. Třída představuje třídu správy modelu CIM (Common Information Model) ze služby WMI, jako je Win32_LogicalDisk, která může představovat diskovou jednotku a Win32_Process, která představuje proces, jako je 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
Cesta ke třídě služby WMI. Třída představuje třídu správy CIM ze služby WMI. Třídy CIM představují informace o správě, včetně hardwaru, softwaru, procesů atd. Další informace o třídách CIM dostupných v Windows naleznete v tématu CIM Classes.
- options
- ObjectGetOptions
Představuje ObjectGetOptions možnosti, které se mají použít při načítání třídy služby WMI.
Příklady
Následující příklad ukazuje, jak inicializovat proměnnou ManagementClass pomocí konstruktoru ManagementClass . V příkladu jsou uvedeny metody, vlastnosti a kvalifikátory (včetně upravených kvalifikátorů) pro vytvořenou třídu.
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
Poznámky
Zabezpečení rozhraní .NET Framework
Plný vztah důvěryhodnosti pro okamžitého volajícího. Tento člen nemůže být používán částečně důvěryhodným kódem. Další informace naleznete v tématu Použití knihoven z částečně důvěryhodného kódu.
Platí pro
ManagementClass(ManagementScope, ManagementPath, ObjectGetOptions)
- Zdroj:
- ManagementClass.cs
- Zdroj:
- ManagementClass.cs
- Zdroj:
- ManagementClass.cs
- Zdroj:
- ManagementClass.cs
Inicializuje novou instanci ManagementClass třídy pro zadanou třídu WMI v zadaném oboru a se zadanými možnostmi. Třída představuje třídu správy modelu CIM (Common Information Model) ze služby WMI, jako je Win32_LogicalDisk, která může představovat diskovou jednotku a Win32_Process, která představuje proces, jako je 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
Určuje ManagementScope obor (server a obor názvů), ve kterém se nachází třída služby WMI.
- path
- ManagementPath
A ManagementPath , který představuje cestu ke třídě WMI v zadaném oboru. Třída představuje třídu správy CIM ze služby WMI. Třídy CIM představují informace o správě, včetně hardwaru, softwaru, procesů atd. Další informace o třídách CIM dostupných v Windows naleznete v tématu CIM Classes.
- options
- ObjectGetOptions
Určuje ObjectGetOptions možnosti, které se mají použít při načítání třídy WMI.
Příklady
Následující příklad je příkladem, jak inicializovat ManagementClass proměnnou pomocí konstruktoru ManagementClass . V příkladu jsou uvedeny metody, vlastnosti a kvalifikátory (včetně upravených kvalifikátorů) pro vytvořenou třídu. Je nutné změnit obor (obor názvů) v kódu, aby se příklad správně spustil na vašem počítači.
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
Poznámky
Cestu je možné zadat jako úplnou cestu (včetně serveru a oboru názvů). Pokud je však zadaný obor, přepíše první část úplné cesty.
Zabezpečení rozhraní .NET Framework
Plný vztah důvěryhodnosti pro okamžitého volajícího. Tento člen nemůže být používán částečně důvěryhodným kódem. Další informace naleznete v tématu Použití knihoven z částečně důvěryhodného kódu.
Platí pro
ManagementClass(String, String, ObjectGetOptions)
- Zdroj:
- ManagementClass.cs
- Zdroj:
- ManagementClass.cs
- Zdroj:
- ManagementClass.cs
- Zdroj:
- ManagementClass.cs
Inicializuje novou instanci ManagementClass třídy pro zadanou třídu WMI v zadaném oboru a se zadanými možnostmi. Třída představuje třídu správy modelu CIM (Common Information Model) ze služby WMI, jako je Win32_LogicalDisk, která může představovat diskovou jednotku a Win32_Process, která představuje proces, jako je 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
Obor, ve kterém se nachází třída služby WMI.
- path
- String
Cesta ke třídě WMI v rámci zadaného oboru. Třída představuje třídu správy CIM ze služby WMI. Třídy CIM představují informace o správě, včetně hardwaru, softwaru, procesů atd. Další informace o třídách CIM dostupných v Windows naleznete v tématu CIM Classes.
- options
- ObjectGetOptions
Určuje ObjectGetOptions možnosti, které se mají použít při načítání třídy WMI.
Příklady
Následující příklad ukazuje, jak inicializovat proměnnou ManagementClass pomocí konstruktoru ManagementClass . V příkladu jsou uvedeny metody, vlastnosti a kvalifikátory (včetně upravených kvalifikátorů) pro vytvořenou třídu. Je nutné změnit obor (obor názvů) v kódu, aby se příklad správně spustil na vašem počítači.
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
Poznámky
Cestu je možné zadat jako úplnou cestu (včetně serveru a oboru názvů). Pokud je však zadaný obor, přepíše první část úplné cesty.
Zabezpečení rozhraní .NET Framework
Plný vztah důvěryhodnosti pro okamžitého volajícího. Tento člen nemůže být používán částečně důvěryhodným kódem. Další informace naleznete v tématu Použití knihoven z částečně důvěryhodného kódu.