public static void Main()
    {
        ManagementClass c =
            new ManagementClass("CIM_LogicalDisk");

        foreach (ManagementClass r in c.GetSubclasses())
        {
            Console.WriteLine(
                "Instances of {0} are sub-classes",
                r["__CLASS"]);
        }

        foreach (ManagementClass r in c.GetRelationshipClasses())
        {
            Console.WriteLine(
                "{0} is a relationship class to " +
                c.ClassPath.ClassName,
                r["__CLASS"]);

            foreach (ManagementClass related in c.GetRelatedClasses(
                         null, r.ClassPath.ClassName,
                         "Association", null, null, null, null))
            {
                Console.WriteLine(
                    "{0} is related to " + c.ClassPath.ClassName,
                    related.ClassPath.ClassName);
            }
        }

        return;
    }
Exemplo n.º 2
0
        public static int Main(string[] args)
        {
            ManagementClass c = new ManagementClass("CIM_Setting");

            foreach (ManagementClass cc in c.GetRelatedClasses())
            {
                Console.WriteLine(cc.ClassPath);
            }

            return(0);
        }
    public static void Main()
    {
        ManagementClass c =
            new ManagementClass("Win32_LogicalDisk");

        foreach (ManagementClass r in c.GetRelatedClasses())
        {
            Console.WriteLine(
                "Instances of {0} are related to this class",
                r["__CLASS"]);
        }

        return;
    }