# HG changeset patch # User Ivo Smits # Date 1396448695 -7200 # Node ID 57b4c2f895d18f1f44e503bac314db4e63ed7970 # Parent 9096f62d18c488dfae553579697a3a8eabc272be USBLib: added DeviceNode.GetStatus diff -r 9096f62d18c4 -r 57b4c2f895d1 Pml/PmlConnection.cs --- a/Pml/PmlConnection.cs Wed Mar 12 19:33:42 2014 +0100 +++ b/Pml/PmlConnection.cs Wed Apr 02 16:24:55 2014 +0200 @@ -307,7 +307,7 @@ } } } catch (System.Threading.ThreadAbortException ex) { - throw ex; + throw; } catch (Exception ex) { Console.WriteLine(ex.ToString()); } finally { diff -r 9096f62d18c4 -r 57b4c2f895d1 USBLib/Windows/Devices/DeviceNode.cs --- 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; } }