Hardware/HDD/WindowsSmart.cs
changeset 325 4c31341a4800
parent 324 c6ee430d6995
child 344 3145aadca3d2
     1.1 --- a/Hardware/HDD/WindowsSmart.cs	Sat Dec 31 17:31:04 2011 +0000
     1.2 +++ b/Hardware/HDD/WindowsSmart.cs	Sun Jan 01 10:14:42 2012 +0000
     1.3 @@ -16,7 +16,7 @@
     1.4  
     1.5    The Initial Developer of the Original Code is 
     1.6    Michael Möller <m.moeller@gmx.ch>.
     1.7 -  Portions created by the Initial Developer are Copyright (C) 2009-2011
     1.8 +  Portions created by the Initial Developer are Copyright (C) 2009-2012
     1.9    the Initial Developer. All Rights Reserved.
    1.10  
    1.11    Contributor(s): 
    1.12 @@ -327,9 +327,20 @@
    1.13          out bytesReturned, IntPtr.Zero); 
    1.14  
    1.15        return (isValid) ? result.Thresholds : new DriveThresholdValue[0];
    1.16 -    } 
    1.17 +    }
    1.18  
    1.19 -    public string ReadName(IntPtr handle, int driveNumber) {
    1.20 +    private string GetString(byte[] bytes) {   
    1.21 +      char[] chars = new char[bytes.Length];
    1.22 +      for (int i = 0; i < bytes.Length; i += 2) {
    1.23 +        chars[i] = (char)bytes[i + 1];
    1.24 +        chars[i + 1] = (char)bytes[i];
    1.25 +      }
    1.26 +      return new string(chars).Trim(new char[] { ' ', '\0' });
    1.27 +    }
    1.28 +
    1.29 +    public bool ReadNameAndFirmwareRevision(IntPtr handle, int driveNumber, 
    1.30 +      out string name, out string firmwareRevision) 
    1.31 +    {
    1.32        DriveCommandParameter parameter = new DriveCommandParameter();
    1.33        DriveIdentifyResult result;
    1.34        uint bytesReturned;
    1.35 @@ -342,19 +353,15 @@
    1.36          out result, Marshal.SizeOf(typeof(DriveIdentifyResult)), 
    1.37          out bytesReturned, IntPtr.Zero);
    1.38  
    1.39 -      if (!valid)
    1.40 -        return null;
    1.41 -      else {
    1.42 +      if (!valid) {
    1.43 +        name = null;
    1.44 +        firmwareRevision = null;
    1.45 +        return false;
    1.46 +      }
    1.47  
    1.48 -        byte[] bytes = result.Identify.ModelNumber;
    1.49 -        char[] chars = new char[bytes.Length];
    1.50 -        for (int i = 0; i < bytes.Length; i += 2) {
    1.51 -          chars[i] = (char)bytes[i + 1];
    1.52 -          chars[i + 1] = (char)bytes[i];
    1.53 -        }
    1.54 -
    1.55 -        return new string(chars).Trim(new char[] {' ', '\0'});
    1.56 -      }
    1.57 +      name = GetString(result.Identify.ModelNumber);
    1.58 +      firmwareRevision = GetString(result.Identify.FirmwareRevision);
    1.59 +      return true;
    1.60      }
    1.61  
    1.62      public void CloseHandle(IntPtr handle) {