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

ManagementObjectCollection.ManagementObjectEnumerator Class

Represents the enumerator on the collection.

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

System.Object
   System.Management.ManagementObjectCollection.ManagementObjectEnumerator

[Visual Basic]
Public Class ManagementObjectCollection.ManagementObjectEnumerator
   Implements IEnumerator, IDisposable
[C#]
public class ManagementObjectCollection.ManagementObjectEnumerator
   : IEnumerator, IDisposable
[C++]
public __gc class
   ManagementObjectCollection.ManagementObjectEnumerator : public
   IEnumerator, IDisposable
[JScript]
public class ManagementObjectCollection.ManagementObjectEnumerator
   implements IEnumerator, IDisposable

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

[C#] 
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;
    }
}
   
[Visual Basic] 
Imports System
                  Imports System.Management
                  ' This sample demonstrates how to enumerate all logical disks
                  ' using ManagementObjectEnumerator object.
                  Class Sample_ManagementObjectEnumerator
                  Overloads Public Shared Function Main(args() As String) As Integer
                  Dim diskClass As New ManagementClass("Win32_LogicalDisk")
                  Dim disks As ManagementObjectCollection = diskClass.GetInstances()
                  Dim disksEnumerator As _
                  ManagementObjectCollection.ManagementObjectEnumerator = _
                  disks.GetEnumerator()
                  While disksEnumerator.MoveNext()
                  Dim disk As ManagementObject = _
                  CType(disksEnumerator.Current, ManagementObject)
                  Console.WriteLine("Disk found: " & disk("deviceid"))
                  End While
                  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

ManagementObjectCollection.ManagementObjectEnumerator Members | System.Management Namespace

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.