public static SafeDeviceInfoSetHandle SetupDiGetClassDevs( Guid? classGuid, string enumerator, IntPtr hwndParent, GetClassDevsFlags flags) { var result = SetupDiGetClassDevs((NullableGuid)classGuid, enumerator, hwndParent, flags); if (result.IsInvalid) { throw new Win32Exception(); } return result; }
public static SafeDeviceInfoSetHandle SetupDiGetClassDevs( Guid?classGuid, string enumerator, IntPtr hwndParent, GetClassDevsFlags flags) { var result = SetupDiGetClassDevs((NullableGuid)classGuid, enumerator, hwndParent, flags); if (result.IsInvalid) { throw new Win32Exception(); } return(result); }
private static DeviceInfoSet GetDevicesInternal(Guid deviceInterfaceId, string enumerator, bool presentDevices, bool currentProfile, GetClassDevsFlags flags = GetClassDevsFlags.None) { if (deviceInterfaceId == DeviceInterfaceClasses.All) { flags |= GetClassDevsFlags.AllClasses; } if (presentDevices) { flags |= GetClassDevsFlags.Present; } if (currentProfile) { flags |= GetClassDevsFlags.Profile; } var deviceInfoSet = SetupDi.GetClassDevs(deviceInterfaceId, enumerator, flags); if (deviceInfoSet != null) { return(deviceInfoSet); } throw new DeviceManagerWindowsException("Unable to enumerate devices."); }
public static extern unsafe SafeDeviceInfoSetHandle SetupDiGetClassDevs( [Friendly(FriendlyFlags.In | FriendlyFlags.Optional)] Guid *classGuid, string enumerator, IntPtr hwndParent, GetClassDevsFlags flags);
public static extern SafeDeviceInfoSetHandle SetupDiGetClassDevs( NullableGuid classGuid, string enumerator, IntPtr hwndParent, GetClassDevsFlags flags);
public SafeDeviceInfoSetHandle SetupDiGetClassDevs( NullableGuid classGuid, string enumerator, IntPtr hwndParent, GetClassDevsFlags flags) => SetupDiGetClassDevs(classGuid, enumerator, hwndParent, flags);
internal static extern IntPtr GetClassDevs( [MarshalAs(UnmanagedType.LPStruct)] Guid deviceInterfaceId, [MarshalAs(UnmanagedType.LPWStr)] string enumerator, IntPtr hwndParent, [MarshalAs(UnmanagedType.U4)] GetClassDevsFlags flags);
/// <summary> /// /// </summary> /// <param name="deviceInterfaceId"></param> /// <param name="enumerator"></param> /// <param name="flags"></param> /// <returns></returns> public static DeviceInfoSet GetClassDevs(Guid deviceInterfaceId, string enumerator, GetClassDevsFlags flags) { var handle = GetClassDevs(deviceInterfaceId, enumerator, IntPtr.Zero, flags); if (handle != Handle.InvalidHandleValue) { return(new DeviceInfoSet(handle)); } return(null); }