comparison USBLib/Windows/Devices/DeviceNode.cs @ 52:d4778c3232ad

Prevent exception in HWLib
author Ivo Smits <Ivo@UCIS.nl>
date Tue, 01 Oct 2013 00:24:39 +0200
parents 556b4fb511bd
children 309c705d7460
comparison
equal deleted inserted replaced
51:e3f37686b15a 52:d4778c3232ad
110 } 110 }
111 public Byte[] GetProperty(CMRDP property) { 111 public Byte[] GetProperty(CMRDP property) {
112 uint proplength = 0; 112 uint proplength = 0;
113 uint proptype; 113 uint proptype;
114 CR ret = SetupApi.CM_Get_DevNode_Registry_Property(DevInst, property, out proptype, null, ref proplength, 0); 114 CR ret = SetupApi.CM_Get_DevNode_Registry_Property(DevInst, property, out proptype, null, ref proplength, 0);
115 if (ret == CR.NO_SUCH_VALUE) return null; 115 if (ret == CR.NO_SUCH_VALUE || ret == CR.NO_SUCH_DEVNODE) return null;
116 if (ret != CR.BUFFER_SMALL) CMException.Throw(ret, "CM_Get_DevNode_Registry_Property"); 116 if (ret != CR.BUFFER_SMALL) CMException.Throw(ret, "CM_Get_DevNode_Registry_Property");
117 Byte[] propbuffer = new Byte[proplength]; 117 Byte[] propbuffer = new Byte[proplength];
118 ret = SetupApi.CM_Get_DevNode_Registry_Property(DevInst, property, out proptype, propbuffer, ref proplength, 0); 118 ret = SetupApi.CM_Get_DevNode_Registry_Property(DevInst, property, out proptype, propbuffer, ref proplength, 0);
119 CMException.Throw(ret, "CM_Get_DevNode_Registry_Property"); 119 CMException.Throw(ret, "CM_Get_DevNode_Registry_Property");
120 if (propbuffer.Length > proplength) Array.Resize(ref propbuffer, (int)proplength); 120 if (propbuffer.Length > proplength) Array.Resize(ref propbuffer, (int)proplength);