RelationshipQuery Class
Collapse the table of content
Expand the table of content

RelationshipQuery Class

Represents a WQL REFERENCES OF data query.

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


[Visual Basic]
Public Class RelationshipQuery
   Inherits WqlObjectQuery
public class RelationshipQuery : WqlObjectQuery
public __gc class RelationshipQuery : public WqlObjectQuery
public class RelationshipQuery 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.


[Visual Basic, C#] The following example searches for all objects related to the 'C:' drive object:

using System;
using System.Management;

class Sample_RelationshipQuery
    public static int Main(string[] args) {
        RelationshipQuery query = 
            new RelationshipQuery("references of {Win32_LogicalDisk.DeviceID='C:'}");
        ManagementObjectSearcher searcher =
            new ManagementObjectSearcher(query);
        foreach (ManagementObject assoc in searcher.Get()) {
            Console.WriteLine("Association class = " + assoc["__CLASS"]);

        return 0;
[Visual Basic] 
Imports System
Imports System.Management
Class Sample_RelatedObjectQuery
    Overloads Public Shared Function Main(args() As String) As Integer
        Dim query As New RelationshipQuery("references of {Win32_LogicalDisk.DeviceID='C:'}")
        Dim searcher As New ManagementObjectSearcher(query)
        Dim assoc As ManagementObject
        For Each assoc In searcher.Get()
            Console.WriteLine("Association class = " & assoc("__CLASS"))
        Next assoc
        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

RelationshipQuery Members | System.Management Namespace

© 2015 Microsoft