EnumerationOptions 构造函数
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
初始化 EnumerationOptions 类的新实例。
重载
| 名称 | 说明 |
|---|---|
| EnumerationOptions() |
使用默认值初始化类的新实例 EnumerationOptions (请参阅有关默认值的各个属性说明)。 这是无参数构造函数。 |
| EnumerationOptions(ManagementNamedValueCollection, TimeSpan, Int32, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean) |
初始化要用于查询或枚举的 EnumerationOptions 类的新实例,允许用户为不同的选项指定值。 |
EnumerationOptions()
- Source:
- ManagementOptions.cs
- Source:
- ManagementOptions.cs
- Source:
- ManagementOptions.cs
- Source:
- ManagementOptions.cs
使用默认值初始化类的新实例 EnumerationOptions (请参阅有关默认值的各个属性说明)。 这是无参数构造函数。
public:
EnumerationOptions();
public EnumerationOptions();
Public Sub New ()
示例
以下示例使用EnumerationOptions构造函数初始化变量EnumerationOptions,然后获取 WMI 类及其子类的所有实例。
using System;
using System.Management;
public class RemoteConnect
{
public static void Main()
{
EnumerationOptions opt = new EnumerationOptions();
// Will enumerate instances of the given class
// and any subclasses.
opt.EnumerateDeep = true;
ManagementClass c = new ManagementClass("CIM_Service");
foreach (ManagementObject o in c.GetInstances(opt))
Console.WriteLine(o["Name"]);
}
}
Imports System.Management
Public Class RemoteConnect
Public Overloads Shared Function Main( _
ByVal args() As String) As Integer
Dim opt As New EnumerationOptions
' Will enumerate instances of the given class
' and any subclasses.
opt.EnumerateDeep = True
Dim mngmtClass As New ManagementClass("CIM_Service")
Dim o As ManagementObject
For Each o In mngmtClass.GetInstances(opt)
Console.WriteLine(o("Name"))
Next o
Return 0
End Function
End Class
注解
.NET Framework 安全性
直接调用方完全信任。 此成员不能由部分受信任的代码使用。 有关详细信息,请参阅 使用部分受信任的代码的库。
适用于
EnumerationOptions(ManagementNamedValueCollection, TimeSpan, Int32, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean)
- Source:
- ManagementOptions.cs
- Source:
- ManagementOptions.cs
- Source:
- ManagementOptions.cs
- Source:
- ManagementOptions.cs
初始化要用于查询或枚举的 EnumerationOptions 类的新实例,允许用户为不同的选项指定值。
public:
EnumerationOptions(System::Management::ManagementNamedValueCollection ^ context, TimeSpan timeout, int blockSize, bool rewindable, bool returnImmediatley, bool useAmendedQualifiers, bool ensureLocatable, bool prototypeOnly, bool directRead, bool enumerateDeep);
public EnumerationOptions(System.Management.ManagementNamedValueCollection context, TimeSpan timeout, int blockSize, bool rewindable, bool returnImmediatley, bool useAmendedQualifiers, bool ensureLocatable, bool prototypeOnly, bool directRead, bool enumerateDeep);
new System.Management.EnumerationOptions : System.Management.ManagementNamedValueCollection * TimeSpan * int * bool * bool * bool * bool * bool * bool * bool -> System.Management.EnumerationOptions
Public Sub New (context As ManagementNamedValueCollection, timeout As TimeSpan, blockSize As Integer, rewindable As Boolean, returnImmediatley As Boolean, useAmendedQualifiers As Boolean, ensureLocatable As Boolean, prototypeOnly As Boolean, directRead As Boolean, enumerateDeep As Boolean)
参数
- context
- ManagementNamedValueCollection
选项上下文对象,其中包含可传递给提供程序的特定于提供程序的信息。
- timeout
- TimeSpan
用于枚举结果的超时值。
- blockSize
- Int32
要从 WMI 一次检索的项数。
- rewindable
- Boolean
true 若要显示结果集可回退(允许多次遍历);否则,为 false.
- returnImmediatley
- Boolean
true 如果显示操作应立即返回(半同步)或阻止,直到所有结果都可用;否则,为 false.
- useAmendedQualifiers
- Boolean
true 如果显示返回的对象应包含修订的(区域设置感知)限定符,则为 ;否则,为 false.
- ensureLocatable
- Boolean
true 以确保所有返回的对象都具有有效的路径;否则,为 false.
- prototypeOnly
- Boolean
true 返回结果集的原型而不是实际结果;否则,为 false.
- directRead
- Boolean
true 仅检索指定类或派生类的对象;否则,为 false.
- enumerateDeep
- Boolean
true 在子类中使用递归枚举;否则,为 false.
示例
以下示例使用EnumerationOptions构造函数初始化变量EnumerationOptions,然后获取 WMI 类及其子类的所有实例。
using System;
using System.Management;
public class RemoteConnect
{
public static void Main()
{
EnumerationOptions opt = new EnumerationOptions(
null, System.TimeSpan.MaxValue,
1, true, true, false,
true, false, false, true);
ManagementClass c = new ManagementClass("CIM_Service");
foreach (ManagementObject o in c.GetInstances(opt))
Console.WriteLine(o["Name"]);
}
}
Imports System.Management
Public Class RemoteConnect
Public Overloads Shared Function Main( _
ByVal args() As String) As Integer
Dim opt As EnumerationOptions
Opt = New EnumerationOptions( _
Nothing, System.TimeSpan.MaxValue, _
1, True, True, False, _
True, False, False, True)
Dim mngmtClass As New ManagementClass("CIM_Service")
Dim o As ManagementObject
For Each o In mngmtClass.GetInstances(opt)
Console.WriteLine(o("Name"))
Next o
Return 0
End Function
End Class
注解
.NET Framework 安全性
直接调用方完全信任。 此成员不能由部分受信任的代码使用。 有关详细信息,请参阅 使用部分受信任的代码的库。