Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

RelationshipQuery Class

Represents a WQL REFERENCES OF data query.

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

System.Object
   System.Management.ManagementQuery
      System.Management.ObjectQuery
         System.Management.WqlObjectQuery
            System.Management.RelationshipQuery

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

Example

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

[C#] 
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.

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

RelationshipQuery Members | System.Management Namespace

Show:
© 2014 Microsoft. All rights reserved.