/// <summary> /// Initializes a new instance of the <see cref="DeviceEnumerator"/> class. /// </summary> /// <param name="deviceClass">The identifier of the associated devices.</param> /// <param name="flags">The flags used to defined the type of expected devices.</param> public DeviceEnumerator(Guid deviceClass, DiGetClassFlags flags) { this.deviceClass = deviceClass; this.deviceSet = SetupApiMethods.GetClassDevs(ref deviceClass, null, IntPtr.Zero, flags); this.interfaceData = new DeviceInterfaceData(); this.index = -1; }
/// <summary> /// Advances the enumerator to the next element of the collection. /// </summary> /// <returns> /// <c>true</c> if the enumerator was successfully advanced to the next element; /// <c>false</c> if the enumerator has passed the end of the collection. /// </returns> public bool MoveNext() { this.index++; bool result = SetupApiMethods.EnumDeviceInterfaces(this.deviceSet, 0, ref this.deviceClass, (uint)this.index, this.interfaceData); this.Current = new Device(this.deviceSet, this.interfaceData); return(result); }