EnumerationOptions 建構函式
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
初始化 EnumerationOptions 類別的新執行個體。
多載
| 名稱 | Description |
|---|---|
| EnumerationOptions() |
初始化一個新的類別實例 EnumerationOptions ,使用預設值(請參見各屬性描述以了解預設值)。 這就是無參數建構子。 |
| EnumerationOptions(ManagementNamedValueCollection, TimeSpan, Int32, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean) |
初始化一個新的類別實例 EnumerationOptions ,用於查詢或列舉,讓使用者能指定不同選項的值。 |
EnumerationOptions()
初始化一個新的類別實例 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)
初始化一個新的類別實例 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 安全性
完全信任當下的來電者。 此成員無法被部分受信任的程式碼使用。 欲了解更多資訊,請參閱 「部分受信任程式碼的函式庫使用」。