Export (0) Print
Expand All

RelatedObjectQuery Class

Represents a WQL ASSOCIATORS OF data query. It can be used for both instances and schema queries.

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

System.Object
   System.Management.ManagementQuery
      System.Management.ObjectQuery
         System.Management.WqlObjectQuery
            System.Management.RelatedObjectQuery

[Visual Basic]
Public Class RelatedObjectQuery
   Inherits WqlObjectQuery
[C#]
public class RelatedObjectQuery : WqlObjectQuery
[C++]
public __gc class RelatedObjectQuery : public WqlObjectQuery
[JScript]
public class RelatedObjectQuery extends WqlObjectQuery

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.

Example

[C#] 
using System;
using System.Management;

// This sample demonstrates how to query all instances associated
// with Win32_LogicalDisk='C:'.

class Sample_RelatedObjectQuery
{
    public static int Main(string[] args) {

        //This query requests all objects related to the 'C:' drive.
        RelatedObjectQuery relatedQuery =
            new RelatedObjectQuery("win32_logicaldisk='c:'");
        ManagementObjectSearcher searcher =
            new ManagementObjectSearcher(relatedQuery);
    
        foreach (ManagementObject relatedObject in searcher.Get()) {
            Console.WriteLine(relatedObject.ToString());
        }
 
        return 0;
    }
}
   
[Visual Basic] 
Imports System
Imports System.Management

' This sample demonstrates how to query all instances associated
' with Win32_LogicalDisk='C:'.

Class Sample_RelatedObjectQuery
    Overloads Public Shared Function Main(args() As String) As Integer
 
        'This query requests all objects related to the 'C:' drive.
        Dim relatedQuery As New RelatedObjectQuery("win32_logicaldisk='c:'")
        Dim searcher As New ManagementObjectSearcher(relatedQuery)
   
        Dim relatedObject As ManagementObject
        For Each relatedObject In  searcher.Get()
            Console.WriteLine(relatedObject.ToString())
        Next relatedObject

        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.

Requirements

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

RelatedObjectQuery Members | System.Management Namespace

Show:
© 2014 Microsoft