diff USBLib/Windows/Devices/DeviceNode.cs @ 90:57b4c2f895d1

USBLib: added DeviceNode.GetStatus
author Ivo Smits <Ivo@UCIS.nl>
date Wed, 02 Apr 2014 16:24:55 +0200
parents 9096f62d18c4
children d467cd38b34e
line wrap: on
line diff
--- a/USBLib/Windows/Devices/DeviceNode.cs	Wed Mar 12 19:33:42 2014 +0100
+++ b/USBLib/Windows/Devices/DeviceNode.cs	Wed Apr 02 16:24:55 2014 +0200
@@ -291,14 +291,17 @@
 			return new DeviceNode(node);
 		}
 
+		public Boolean GetStatus(out UInt32 status, out UInt32 problem) {
+			CR ret = SetupApi.CM_Get_DevNode_Status(out status, out problem, DevInst, 0);
+			if (ret == CR.NO_SUCH_DEVNODE) return false;
+			CMException.Throw(ret, "CM_Get_DevNode_Status");
+			return true;
+		}
+
 		public Boolean Present {
 			get {
 				UInt32 status, problem;
-				CR ret = SetupApi.CM_Get_DevNode_Status(out status, out problem, DevInst, 0);
-				if (ret == CR.NO_SUCH_DEVNODE) return false;
-				CMException.Throw(ret, "CM_Get_DevNode_Status");
-				if (status == 25174016) return false;
-				return true;
+				return GetStatus(out status, out problem) && status != 25174016;
 			}
 		}