This documentation is archived and is not being maintained.

WqlObjectQuery Class

Represents a WMI data query in WQL format.

For a list of all members of this type, see WqlObjectQuery Members.


[Visual Basic]
Public Class WqlObjectQuery
   Inherits ObjectQuery
public class WqlObjectQuery : ObjectQuery
public __gc class WqlObjectQuery : public ObjectQuery
public class WqlObjectQuery extends ObjectQuery

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.


using System; 
using System.Management; 

// This sample demonstrates how to use a WqlObjectQuery class to 
// perform an object query. 

class Sample_WqlObjectQuery 
    public static int Main(string[] args) {
        WqlObjectQuery objectQuery = new WqlObjectQuery("select * from Win32_Share");
        ManagementObjectSearcher searcher =
            new ManagementObjectSearcher(objectQuery);

        foreach (ManagementObject share in searcher.Get()) { 
            Console.WriteLine("Share = " + share["Name"]);

        return 0;
[Visual Basic] 
Imports System
Imports System.Management

' This sample demonstrate how to use a WqlObjectQuery class to
' perform an object query.

Class Sample_WqlObjectQuery
    Overloads Public Shared Function Main(args() As String) As Integer
        Dim objectQuery As New WqlObjectQuery("select * from Win32_Share")
        Dim searcher As New ManagementObjectSearcher(objectQuery)
        Dim share As ManagementObject
        For Each share In searcher.Get()
            Console.WriteLine("Share = " & share("Name"))
        Next share

        Return 0
    End Function
End Class

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.


Namespace: System.Management

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: System.Management (in System.Management.dll)

See Also

WqlObjectQuery Members | System.Management Namespace