예제 #1
0
        public static LogicalDisk[] FillLogicalDisks(string machineName, string userName, string password,
                                                     string queryArea)
        {
            InitializeScope(machineName, userName, password);
            ManagementClass managementClass = new ManagementClass(path + ":" + queryArea);

            if (mScope != null)
            {
                managementClass.Scope = mScope;
            }
            ManagementObjectCollection instances = managementClass.GetInstances();

            if (instances == null)
            {
                return(null);
            }
            LogicalDisk[] logicalDisks = new LogicalDisk[instances.Count];
            ManagementObjectCollection.ManagementObjectEnumerator enumerator = instances.GetEnumerator();
            int i = 0;

            while (enumerator.MoveNext())
            {
                logicalDisks[i] = new LogicalDisk((ManagementObject)enumerator.Current);
                i++;
            }
            return(logicalDisks);
        }
예제 #2
0
 public static LogicalDisk[] FillLogicalDisks(string machineName, string userName, string password,
                                              string queryArea)
 {
     InitializeScope(machineName, userName, password);
     ManagementClass managementClass = new ManagementClass(path + ":" + queryArea);
     if (mScope != null)
     {
         managementClass.Scope = mScope;
     }
     ManagementObjectCollection instances = managementClass.GetInstances();
     if (instances == null)
     {
         return null;
     }
     LogicalDisk[] logicalDisks = new LogicalDisk[instances.Count];
     ManagementObjectCollection.ManagementObjectEnumerator enumerator = instances.GetEnumerator();
     int i = 0;
     while (enumerator.MoveNext())
     {
         logicalDisks[i] = new LogicalDisk((ManagementObject) enumerator.Current);
         i++;
     }
     return logicalDisks;
 }