// Token: 0x0600021A RID: 538 RVA: 0x00015FF4 File Offset: 0x000141F4 public static int EnumerateDevices(uint DeviceIndex, string ClassName, StringBuilder DeviceName) { uint num = 0u; Guid empty = Guid.Empty; Guid[] array = new Guid[1]; DeviceInfo.SP_DEVINFO_DATA sp_DEVINFO_DATA = new DeviceInfo.SP_DEVINFO_DATA(); bool flag = DeviceInfo.SetupDiClassGuidsFromNameA(ClassName, ref array[0], num, ref num); if (num == 0u) { DeviceName = new StringBuilder(""); return(-2); } if (!flag) { array = new Guid[num]; flag = DeviceInfo.SetupDiClassGuidsFromNameA(ClassName, ref array[0], num, ref num); if (!flag || num == 0u) { DeviceName = new StringBuilder(""); return(-2); } } IntPtr deviceInfoSet = DeviceInfo.SetupDiGetClassDevsA(ref array[0], 0u, IntPtr.Zero, 2u); if (deviceInfoSet.ToInt32() == -1) { DeviceName = new StringBuilder(""); return(-3); } sp_DEVINFO_DATA.cbSize = 28; sp_DEVINFO_DATA.DevInst = 0; sp_DEVINFO_DATA.ClassGuid = Guid.Empty; sp_DEVINFO_DATA.Reserved = 0UL; if (!DeviceInfo.SetupDiEnumDeviceInfo(deviceInfoSet, DeviceIndex, sp_DEVINFO_DATA)) { DeviceInfo.SetupDiDestroyDeviceInfoList(deviceInfoSet); DeviceName = new StringBuilder(""); return(-1); } DeviceName.Capacity = 1000; if (!DeviceInfo.SetupDiGetDeviceRegistryPropertyA(deviceInfoSet, sp_DEVINFO_DATA, 12u, 0u, DeviceName, 1000u, IntPtr.Zero) && !DeviceInfo.SetupDiGetDeviceRegistryPropertyA(deviceInfoSet, sp_DEVINFO_DATA, 0u, 0u, DeviceName, 1000u, IntPtr.Zero)) { DeviceInfo.SetupDiDestroyDeviceInfoList(deviceInfoSet); DeviceName = new StringBuilder(""); return(-4); } return(0); }
private static extern bool SetupDiGetDeviceRegistryPropertyA(IntPtr DeviceInfoSet, DeviceInfo.SP_DEVINFO_DATA DeviceInfoData, uint Property, uint PropertyRegDataType, StringBuilder PropertyBuffer, uint PropertyBufferSize, IntPtr RequiredSize);
private static extern bool SetupDiEnumDeviceInfo(IntPtr DeviceInfoSet, uint MemberIndex, DeviceInfo.SP_DEVINFO_DATA DeviceInfoData);