Mercurial > hg > ucis.core
changeset 90:57b4c2f895d1
USBLib: added DeviceNode.GetStatus
author | Ivo Smits <Ivo@UCIS.nl> |
---|---|
date | Wed, 02 Apr 2014 16:24:55 +0200 |
parents | 9096f62d18c4 |
children | 3347e1758e55 |
files | Pml/PmlConnection.cs USBLib/Windows/Devices/DeviceNode.cs |
diffstat | 2 files changed, 9 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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 {
--- 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; } }