This documentation is archived and is not being maintained.

ManagementObjectCollection.ManagementObjectEnumerator Class

Represents the enumerator on the collection.

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


[Visual Basic]
Public Class ManagementObjectCollection.ManagementObjectEnumerator
   Implements IEnumerator, IDisposable
public class ManagementObjectCollection.ManagementObjectEnumerator
   : IEnumerator, IDisposable
public __gc class
   ManagementObjectCollection.ManagementObjectEnumerator : public
   IEnumerator, IDisposable
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.


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 =
        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 = _
                  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.


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