发现一个问题,有个类没法实例化~(IDE问题,已经OK)

ManagementObjectCollection.ManagementObjectEnumerator不能使用,不知道是不是private?但是MSDN上提供了类的介绍。

MSDN上的demo如下:
using System;
using System.Management;

// This example demonstrates how to enumerate all logical disks
// using the ManagementObjectEnumerator object.
class Sample_ManagementObjectEnumerator
{
    public static int Main(string[] args) {
        ManagementClass diskClass = new ManagementClass("Win32_LogicalDisk");
        ManagementObjectCollection disks = diskClass.GetInstances();
        ManagementObjectCollection.ManagementObjectEnumerator disksEnumerator =
            disks.GetEnumerator();
        while(disksEnumerator.MoveNext()) {
            ManagementObject disk = (ManagementObject)disksEnumerator.Current;
           Console.WriteLine("Disk found: " + disk["deviceid"]);
        }
        return 0;
    }
}

posted @ 2004-06-07 21:08  mp3 swf  阅读(639)  评论(3编辑  收藏  举报