Szerkesztés

Megosztás a következőn keresztül:


ManagementObjectSearcher.Get Method

Definition

Invokes the specified WMI query.

Overloads

Get()

Invokes the specified WMI query and returns the resulting collection.

Get(ManagementOperationObserver)

Invokes the WMI query asynchronously, and binds to a watcher to deliver the results.

Get()

Source:
ManagementObjectSearcher.cs
Source:
ManagementObjectSearcher.cs
Source:
ManagementObjectSearcher.cs
Source:
ManagementObjectSearcher.cs

Invokes the specified WMI query and returns the resulting collection.

public:
 System::Management::ManagementObjectCollection ^ Get();
public System.Management.ManagementObjectCollection Get ();
member this.Get : unit -> System.Management.ManagementObjectCollection
Public Function Get () As ManagementObjectCollection

Returns

A ManagementObjectCollection containing the objects that match the specified query.

Examples

The following example initializes a new instance of the ManagementObjectSearcher class with a specific query, scope, and enumeration options.

using System;
using System.Management;

public class Sample
{
    public static void Main(string[] args)
    {
        ManagementObjectSearcher s =
            new ManagementObjectSearcher(
            "root\\CIMV2",
            "SELECT * FROM Win32_Service",
            new EnumerationOptions(
            null, System.TimeSpan.MaxValue,
            1, true, false, true,
            true, false, true, true));

        foreach (ManagementObject service in s.Get())
        {
            // show the service
            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 ManagementObjectSearcher( _
            "root\MyApp", _
            "SELECT * FROM Win32_Service", _
            New EnumerationOptions( _
            Nothing, System.TimeSpan.MaxValue, 1, _
            True, False, True, True, False, _
            True, True))


        For Each service As ManagementObject In s.Get()
            'show the instance
            Console.WriteLine(service.ToString())
        Next


    End Function 'Main
End Class

Remarks

.NET Framework Security

Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.

Applies to

Get(ManagementOperationObserver)

Source:
ManagementObjectSearcher.cs
Source:
ManagementObjectSearcher.cs
Source:
ManagementObjectSearcher.cs
Source:
ManagementObjectSearcher.cs

Invokes the WMI query asynchronously, and binds to a watcher to deliver the results.

public:
 void Get(System::Management::ManagementOperationObserver ^ watcher);
public void Get (System.Management.ManagementOperationObserver watcher);
member this.Get : System.Management.ManagementOperationObserver -> unit
Public Sub Get (watcher As ManagementOperationObserver)

Parameters

watcher
ManagementOperationObserver

The watcher that raises events triggered by the operation.

Remarks

.NET Framework Security

Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.

Applies to