changeset 52:d4778c3232ad

Prevent exception in HWLib
author Ivo Smits <Ivo@UCIS.nl>
date Tue, 01 Oct 2013 00:24:39 +0200
parents e3f37686b15a
children df5534af12e9
files USBLib/Communication/WindowsUsbDeviceRegistry.cs USBLib/Windows/Devices/DeviceNode.cs
diffstat 2 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/USBLib/Communication/WindowsUsbDeviceRegistry.cs	Mon Sep 30 21:24:35 2013 +0200
+++ b/USBLib/Communication/WindowsUsbDeviceRegistry.cs	Tue Oct 01 00:24:39 2013 +0200
@@ -10,7 +10,7 @@
 		public DeviceNode DeviceNode { get; private set; }
 
 		public static Boolean DecodeDeviceIDs(DeviceNode device, out int vendorID, out int productID, out int revision, out int interfaceID) {
-			String[] hwids = device.GetPropertyStringArray(CMRDP.HARDWAREID);
+			String[] hwids = device.HardwareID;
 			String hwid = null;
 			if (hwids == null || hwids.Length < 1 || hwids[0].Length == 0) {
 				hwid = device.DeviceID;
--- a/USBLib/Windows/Devices/DeviceNode.cs	Mon Sep 30 21:24:35 2013 +0200
+++ b/USBLib/Windows/Devices/DeviceNode.cs	Tue Oct 01 00:24:39 2013 +0200
@@ -112,7 +112,7 @@
 			uint proplength = 0;
 			uint proptype;
 			CR ret = SetupApi.CM_Get_DevNode_Registry_Property(DevInst, property, out proptype, null, ref proplength, 0);
-			if (ret == CR.NO_SUCH_VALUE) return null;
+			if (ret == CR.NO_SUCH_VALUE || ret == CR.NO_SUCH_DEVNODE) return null;
 			if (ret != CR.BUFFER_SMALL) CMException.Throw(ret, "CM_Get_DevNode_Registry_Property");
 			Byte[] propbuffer = new Byte[proplength];
 			ret = SetupApi.CM_Get_DevNode_Registry_Property(DevInst, property, out proptype, propbuffer, ref proplength, 0);