Hardware/TBalancer/TBalancerGroup.cs
changeset 216 b5b076457b68
parent 195 0ee888c485d5
child 256 6dc6410489f4
     1.1 --- a/Hardware/TBalancer/TBalancerGroup.cs	Wed Oct 06 19:18:07 2010 +0000
     1.2 +++ b/Hardware/TBalancer/TBalancerGroup.cs	Wed Oct 06 19:50:10 2010 +0000
     1.3 @@ -51,14 +51,25 @@
     1.4  
     1.5        uint numDevices;
     1.6        try {
     1.7 -        FTD2XX.FT_CreateDeviceInfoList(out numDevices);
     1.8 +        if (FTD2XX.FT_CreateDeviceInfoList(out numDevices) != FT_STATUS.FT_OK) {
     1.9 +          report.AppendLine("Status: FT_CreateDeviceInfoList failed");
    1.10 +          return;
    1.11 +        }
    1.12        } catch (DllNotFoundException) { return; } 
    1.13          catch (ArgumentNullException) { return; }
    1.14          catch (EntryPointNotFoundException) { return; }
    1.15          catch (BadImageFormatException) { return; }
    1.16       
    1.17        FT_DEVICE_INFO_NODE[] info = new FT_DEVICE_INFO_NODE[numDevices];
    1.18 -      FTD2XX.FT_GetDeviceInfoList(info, ref numDevices);
    1.19 +      if (FTD2XX.FT_GetDeviceInfoList(info, ref numDevices) != FT_STATUS.FT_OK) 
    1.20 +      {
    1.21 +        report.AppendLine("Status: FT_GetDeviceInfoList failed");        
    1.22 +        return;
    1.23 +      }
    1.24 +
    1.25 +      // make sure numDevices is not larger than the info array
    1.26 +      if (numDevices > info.Length)
    1.27 +        numDevices = (uint)info.Length;
    1.28  
    1.29        for (int i = 0; i < numDevices; i++) {
    1.30          report.Append("Device Index: ");