SelectQuery コンストラクター
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
SelectQuery クラスの新しいインスタンスを初期化します。
オーバーロード
| 名前 | 説明 |
|---|---|
| SelectQuery() |
SelectQuery クラスの新しいインスタンスを初期化します。 これはパラメーターなしのコンストラクターです。 |
| SelectQuery(String) |
指定したクエリまたは指定したクラス名の SelectQuery クラスの新しいインスタンスを初期化します。 |
| SelectQuery(Boolean, String) |
必要に応じて条件を指定して、スキーマ クエリの SelectQuery クラスの新しいインスタンスを初期化します。 |
| SelectQuery(String, String) |
指定したクラス名と条件を使用して、 SelectQuery クラスの新しいインスタンスを初期化します。 |
| SelectQuery(String, String, String[]) |
指定したプロパティのみを選択して、指定したクラス名と条件を使用して、 SelectQuery クラスの新しいインスタンスを初期化します。 |
SelectQuery()
SelectQuery クラスの新しいインスタンスを初期化します。 これはパラメーターなしのコンストラクターです。
public:
SelectQuery();
public SelectQuery();
Public Sub New ()
注釈
.NET Framework のセキュリティ
直接呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されたコードでは使用できません。 詳細については、「 部分信頼コードからのライブラリの使用」を参照してください。
適用対象
SelectQuery(String)
指定したクエリまたは指定したクラス名の SelectQuery クラスの新しいインスタンスを初期化します。
public:
SelectQuery(System::String ^ queryOrClassName);
public SelectQuery(string queryOrClassName);
new System.Management.SelectQuery : string -> System.Management.SelectQuery
Public Sub New (queryOrClassName As String)
パラメーター
- queryOrClassName
- String
クエリ全体、またはクエリで使用するクラス名。 このクラスのパーサーは、文字列を有効な WQL SELECT クエリとして解析しようとします。 パーサーが失敗した場合は、文字列がクラス名であると見なされます。
例
次の例では、クエリを指定して SelectQuery を初期化します。
using System;
using System.Management;
class Sample
{
public static void Main(string[] args)
{
SelectQuery sQuery =
new SelectQuery(
"SELECT * FROM Win32_Service WHERE State='Stopped'");
// or
// This is equivalent to "SELECT * FROM Win32_Service"
SelectQuery query = new SelectQuery("Win32_Service");
}
}
Imports System.Management
Public Class Sample
Public Overloads Shared Function _
Main(ByVal args() As String) As Integer
Dim sQuery As New SelectQuery( _
"SELECT * FROM Win32_Service WHERE State='Stopped'")
'or
'This is equivalent to "SELECT * FROM Win32_Service"
Dim query As New SelectQuery("Win32_Service")
End Function
End Class
注釈
.NET Framework のセキュリティ
直接呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されたコードでは使用できません。 詳細については、「 部分信頼コードからのライブラリの使用」を参照してください。
適用対象
SelectQuery(Boolean, String)
必要に応じて条件を指定して、スキーマ クエリの SelectQuery クラスの新しいインスタンスを初期化します。
public:
SelectQuery(bool isSchemaQuery, System::String ^ condition);
public SelectQuery(bool isSchemaQuery, string condition);
new System.Management.SelectQuery : bool * string -> System.Management.SelectQuery
Public Sub New (isSchemaQuery As Boolean, condition As String)
パラメーター
- isSchemaQuery
- Boolean
true これがスキーマ クエリであることを示す場合。それ以外の場合は false。 このコンストラクターでは、 false 値が無効です。
- condition
- String
クラスの結果セットを形成するために適用される条件。
例
次の例では、条件を指定して SelectQuery を初期化します。
using System;
using System.Management;
public class Sample
{
public static void Main(string[] args)
{
SelectQuery s =
new SelectQuery(true,
"__CLASS = 'Win32_Service'");
ManagementObjectSearcher searcher =
new ManagementObjectSearcher(
s);
foreach (ManagementObject service in searcher.Get())
{
// show the class
Console.WriteLine(service.ToString());
}
}
}
Imports System.Management
Public Class Sample
Public Overloads Shared Function _
Main(ByVal args() As String) As Integer
Dim s As New SelectQuery( _
True, "__CLASS = ""Win32_Service""")
Dim searcher As ManagementObjectSearcher
searcher = New ManagementObjectSearcher(s)
For Each service As ManagementObject In searcher.Get()
'show the class
Console.WriteLine(service.ToString())
Next
End Function 'Main
End Class
注釈
.NET Framework のセキュリティ
直接呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されたコードでは使用できません。 詳細については、「 部分信頼コードからのライブラリの使用」を参照してください。
適用対象
SelectQuery(String, String)
指定したクラス名と条件を使用して、 SelectQuery クラスの新しいインスタンスを初期化します。
public:
SelectQuery(System::String ^ className, System::String ^ condition);
public SelectQuery(string className, string condition);
new System.Management.SelectQuery : string * string -> System.Management.SelectQuery
Public Sub New (className As String, condition As String)
パラメーター
- className
- String
クエリで選択するクラスの名前。
- condition
- String
クエリに適用される条件。
例
次の例では、WMI クラス名と条件を指定して SelectQuery を初期化します。
using System;
using System.Management;
public class Sample
{
public static void Main(string[] args)
{
SelectQuery s =
new SelectQuery("Win32_Service",
"State = 'Stopped'");
ManagementObjectSearcher searcher =
new ManagementObjectSearcher(
s);
foreach (ManagementObject service in searcher.Get())
{
// show the class
Console.WriteLine(service.ToString());
}
}
}
Imports System.Management
Public Class Sample
Public Overloads Shared Function _
Main(ByVal args() As String) As Integer
Dim s As New SelectQuery("Win32_Service", _
"State = 'Stopped'")
Dim searcher As ManagementObjectSearcher
searcher = New ManagementObjectSearcher(s)
For Each service As ManagementObject In searcher.Get()
'show the class
Console.WriteLine(service.ToString())
Next
End Function 'Main
End Class
注釈
.NET Framework のセキュリティ
直接呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されたコードでは使用できません。 詳細については、「 部分信頼コードからのライブラリの使用」を参照してください。
適用対象
SelectQuery(String, String, String[])
指定したプロパティのみを選択して、指定したクラス名と条件を使用して、 SelectQuery クラスの新しいインスタンスを初期化します。
public:
SelectQuery(System::String ^ className, System::String ^ condition, cli::array <System::String ^> ^ selectedProperties);
public SelectQuery(string className, string condition, string[] selectedProperties);
new System.Management.SelectQuery : string * string * string[] -> System.Management.SelectQuery
Public Sub New (className As String, condition As String, selectedProperties As String())
パラメーター
- className
- String
選択するクラスの名前。
- condition
- String
選択したクラスのインスタンスに適用される条件。
- selectedProperties
- String[]
クエリ結果で返されるプロパティ名の配列。
例
次の例では、WMI クラス名、条件、およびプロパティの配列を指定して、 SelectQuery を初期化します。
using System;
using System.Management;
public class Sample
{
public static void Main(string[] args)
{
String[] properties =
{"Name", "Handle"};
SelectQuery s = new SelectQuery("Win32_Process",
"Name = 'notepad.exe'",
properties);
ManagementObjectSearcher searcher =
new ManagementObjectSearcher(
s);
foreach (ManagementObject o in searcher.Get())
{
// show the class
Console.WriteLine(o.ToString());
}
}
}
Imports System.Management
Public Class Sample
Public Overloads Shared Function _
Main(ByVal args() As String) As Integer
Dim properties() As String = _
{"Name", "Handle"}
Dim s As New SelectQuery("Win32_Process", _
"Name = 'notepad.exe'", _
properties)
Dim searcher As ManagementObjectSearcher
searcher = New ManagementObjectSearcher(s)
For Each o As ManagementObject In searcher.Get()
'show the class
Console.WriteLine(o.ToString())
Next
End Function 'Main
End Class
注釈
.NET Framework のセキュリティ
直接呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されたコードでは使用できません。 詳細については、「 部分信頼コードからのライブラリの使用」を参照してください。