正在阅读:.Net基础:使用WMI获得硬盘的信息.Net基础:使用WMI获得硬盘的信息

2004-02-14 09:34 出处:CSDN 作者:acewang 责任编辑:linjixiong


      int idx = 0;
       ManagementObjectCollection drives = driveClass.GetInstances();
        foreach (ManagementObject drv in drives) 
        { 
        Console.WriteLine(" Drive({0}) Properties ", idx+1);
          foreach (string strProp in propNames)
          {
           Console.WriteLine("Property: {0}, Value: {1}", strProp, drv[strProp]);
                            }
                     }
              }
       }
  }    
 
  .net Framework SDK自带的帮助里有获得逻辑硬盘大小的代码:
  [C#]

  using System;

  using System.Management;       

   // This example demonstrates getting information about a class using the ManagementClass object

  class Sample_ManagementClass

  {

       public static int Main(string[] args)

察看评论详细内容 我要发表评论
作者笔名简短内容 发表时间
:

键盘也能翻页,试试“← →”键

关注我们

最新资讯离线随时看 聊天吐槽赢奖品