none
get all information from hard disk using vb.net RRS feed

  • Question

  • i want to get all information from my hard drive, for example i want know badsector,temperature etc

    so anyone can help me ???
    • Edited by sastro381 Thursday, March 9, 2017 7:49 AM
    • Moved by DotNet Wang Friday, March 10, 2017 1:51 AM VB related
    Thursday, March 9, 2017 7:48 AM

All replies

  • Hi sastro381,

    Like your title said, since you want to use vb.net.  I will move your case to VB forum for better support.

    Best regards,

    Kristin


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, March 10, 2017 1:26 AM
  • i want to get all information from my hard drive, for example i want know badsector,temperature etc

    so anyone can help me ???

    This should get you started, I found this HERE, converted to VB.NET and cleaned up the formatting.
    Requires a Form with a Button (BtnGo) and a Multiline TextBox(TXTResults)
    Also requires a reference to System.Management in Project, Properties,References.
    MUST be run as admin. I am NOT Llewellyn Kruger 

    Code:

    'Copyright(c) 2013, Llewellyn Kruger
    'All rights reserved.
    'Redistribution And use In source And binary forms, with Or without modification, are permitted provided that the following conditions are met
    'Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    'Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 
    'the following disclaimer in the documentation And/Or other materials provided with the distribution.
    'THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS And CONTRIBUTORS “AS IS” AND ANY EXPRESS Or IMPLIED WARRANTIES, 
    'INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES Of MERCHANTABILITY And FITNESS For A PARTICULAR PURPOSE ARE DISCLAIMED. 
    'In NO Event SHALL THE COPYRIGHT HOLDER Or CONTRIBUTORS BE LIABLE For ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 
    'Or CONSEQUENTIAL DAMAGES (INCLUDING, BUT Not LIMITED To, PROCUREMENT Of SUBSTITUTE GOODS Or SERVICES; LOSS Of USE, DATA,
    'Or PROFITS; Or BUSINESS INTERRUPTION) HOWEVER CAUSED And On ANY THEORY Of LIABILITY, WHETHER In CONTRACT, STRICT LIABILITY, 
    'Or TORT (INCLUDING NEGLIGENCE Or OTHERWISE) ARISING In ANY WAY OUT Of THE USE Of THIS SOFTWARE, EVEN If ADVISED Of THE POSSIBILITY Of SUCH DAMAGE. 
    'MUST BE RUN WITH ELEVATED PERMISSIONS
    'FORM WITH A BUTTON (BtnGo) and a MultiLine TextBox (TXTResults)
    Option Infer On
    Imports Microsoft.VisualBasic
    Imports System
    Imports System.Collections.Generic
    Imports System.Management '****** Add a reference to System.Management in Project,Properties,References ******
    
    Public Class Form1
        Private Sub BtnGo_Click(sender As Object, e As EventArgs) Handles BtnGo.Click
            Dim SB As New System.Text.StringBuilder
            Try
    
                ' retrieve list of drives on computer (this will return both HDD's and CDROM's and Virtual CDROM's)                    
                Dim dicDrives = New Dictionary(Of Integer, HDD)()
    
                Dim wdSearcher = New ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive")
    
                ' extract model and interface information
                Dim iDriveIndex As Integer = 0
                For Each drive As ManagementObject In wdSearcher.Get()
                    Dim hdd = New HDD()
                    hdd.Model = drive("Model").ToString().Trim()
                    hdd.Type = drive("InterfaceType").ToString().Trim()
                    dicDrives.Add(iDriveIndex, hdd)
                    iDriveIndex += 1
                Next drive
    
                Dim pmsearcher = New ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia")
    
                ' retrieve hdd serial number
                iDriveIndex = 0
                For Each drive As ManagementObject In pmsearcher.Get()
                    ' because all physical media will be returned we need to exit
                    ' after the hard drives serial info is extracted
                    If iDriveIndex >= dicDrives.Count Then
                        Exit For
                    End If
                    If (drive("SerialNumber")) Is Nothing Then
                        dicDrives(iDriveIndex).Serial = "None"
                    Else
                        dicDrives(iDriveIndex).Serial = drive("SerialNumber").ToString().Trim()
                    End If
    
                    'dicDrives(iDriveIndex).Serial = If(drive("SerialNumber") Is Nothing, "None", drive("SerialNumber").ToString().Trim())
                    iDriveIndex += 1
                Next drive
    
                ' get wmi access to hdd 
                Dim searcher = New ManagementObjectSearcher("Select * from Win32_DiskDrive")
                searcher.Scope = New ManagementScope("\root\wmi")
    
                ' check if SMART reports the drive is failing
                searcher.Query = New ObjectQuery("Select * from MSStorageDriver_FailurePredictStatus")
                iDriveIndex = 0
                For Each drive As ManagementObject In searcher.Get()
                    dicDrives(iDriveIndex).IsOK = DirectCast(drive.Properties("PredictFailure").Value, Boolean) = False
                    iDriveIndex += 1
                Next drive
    
                ' retrive attribute flags, value worste and vendor data information
                searcher.Query = New ObjectQuery("Select * from MSStorageDriver_FailurePredictData")
                iDriveIndex = 0
                For Each data As ManagementObject In searcher.Get()
                    Dim bytes() As Byte = DirectCast(data.Properties("VendorSpecific").Value, Byte())
                    For i As Integer = 0 To 29
                        Try
                            Dim id As Integer = bytes(i * 12 + 2)
    
                            Dim flags As Integer = bytes(i * 12 + 4) ' least significant status byte, +3 most significant byte, but not used so ignored.
                            'bool advisory = (flags & 0x1) == 0x0;
                            Dim failureImminent As Boolean = (flags And &H1) = &H1
                            'bool onlineDataCollection = (flags & 0x2) == 0x2;
    
                            Dim value As Integer = bytes(i * 12 + 5)
                            Dim worst As Integer = bytes(i * 12 + 6)
                            Dim vendordata As Integer = BitConverter.ToInt32(bytes, i * 12 + 7)
                            If id = 0 Then
                                Continue For
                            End If
    
                            Dim attr = dicDrives(iDriveIndex).Attributes(id)
                            attr.Current = value
                            attr.Worst = worst
                            attr.Data = vendordata
                            attr.IsOK = failureImminent = False
                        Catch
                            ' given key does not exist in attribute collection (attribute not in the dictionary of attributes)
                        End Try
                    Next i
                    iDriveIndex += 1
                Next data
    
                ' retreive threshold values foreach attribute
                searcher.Query = New ObjectQuery("Select * from MSStorageDriver_FailurePredictThresholds")
                iDriveIndex = 0
                For Each data As ManagementObject In searcher.Get()
                    Dim bytes() As Byte = DirectCast(data.Properties("VendorSpecific").Value, Byte())
                    For i As Integer = 0 To 29
                        Try
    
                            Dim id As Integer = bytes(i * 12 + 2)
                            Dim thresh As Integer = bytes(i * 12 + 3)
                            If id = 0 Then
                                Continue For
                            End If
    
                            Dim attr = dicDrives(iDriveIndex).Attributes(id)
                            attr.Threshold = thresh
                        Catch
                            ' given key does not exist in attribute collection (attribute not in the dictionary of attributes)
                        End Try
                    Next i
    
                    iDriveIndex += 1
                Next data
    
                For Each drive In dicDrives
                    SB.AppendLine("-----------------------------------------------------")
                    SB.AppendLine("DRIVE : " & drive.Value.Serial & " - " & drive.Value.Model & " - " & drive.Value.Type & " - " & drive.Value.IsOK.ToString)
                    SB.AppendLine("-----------------------------------------------------")
                    SB.AppendLine("")
    
                    SB.AppendLine("ID                                      Current   Worst     Threshold Data      Status")
                    For Each attr In drive.Value.Attributes
                        If attr.Value.HasData Then
                            SB.AppendLine(attr.Value.Attribute.PadRight(40, " ") & attr.Value.Current.ToString.PadRight(10) &
                                          attr.Value.Worst.ToString.PadRight(10) & attr.Value.Threshold.ToString.PadRight(10) & attr.Value.Data.ToString.PadRight(10) & attr.Value.IsOK.ToString)
                        End If
                    Next attr
                    SB.AppendLine()
                    SB.AppendLine()
                    SB.AppendLine()
                Next drive
    
                Console.ReadLine()
            Catch ex As ManagementException
                SB.AppendLine("An error occurred while querying for WMI data: " & ex.Message)
            End Try
            TXTResults.Text = SB.ToString
        End Sub
    End Class
    
    
    Public Class HDD
    
        Public Property Index() As Integer
        Public Property IsOK() As Boolean
        Public Property Model() As String
        Public Property Type() As String
        Public Property Serial() As String
        Public Attributes As New Dictionary(Of Integer, Smart)() From {
            {&H0, New Smart("Invalid")},
            {&H1, New Smart("Raw read error rate")},
            {&H2, New Smart("Throughput performance")},
            {&H3, New Smart("Spinup time")},
            {&H4, New Smart("Start/Stop count")},
            {&H5, New Smart("Reallocated sector count")},
            {&H6, New Smart("Read channel margin")},
            {&H7, New Smart("Seek error rate")},
            {&H8, New Smart("Seek timer performance")},
            {&H9, New Smart("Power-on hours count")},
            {&HA, New Smart("Spinup retry count")},
            {&HB, New Smart("Calibration retry count")},
            {&HC, New Smart("Power cycle count")},
            {&HD, New Smart("Soft read error rate")},
            {&HB8, New Smart("End-to-End error")},
            {&HBE, New Smart("Airflow Temperature")},
            {&HBF, New Smart("G-sense error rate")},
            {&HC0, New Smart("Power-off retract count")},
            {&HC1, New Smart("Load/Unload cycle count")},
            {&HC2, New Smart("HDD temperature")},
            {&HC3, New Smart("Hardware ECC recovered")},
            {&HC4, New Smart("Reallocation count")},
            {&HC5, New Smart("Current pending sector count")},
            {&HC6, New Smart("Offline scan uncorrectable count")},
            {&HC7, New Smart("UDMA CRC error rate")},
            {&HC8, New Smart("Write error rate")},
            {&HC9, New Smart("Soft read error rate")},
            {&HCA, New Smart("Data Address Mark errors")},
            {&HCB, New Smart("Run out cancel")},
            {&HCC, New Smart("Soft ECC correction")},
            {&HCD, New Smart("Thermal asperity rate (TAR)")},
            {&HCE, New Smart("Flying height")},
            {&HCF, New Smart("Spin high current")},
            {&HD0, New Smart("Spin buzz")},
            {&HD1, New Smart("Offline seek performance")},
            {&HDC, New Smart("Disk shift")},
            {&HDD, New Smart("G-sense error rate")},
            {&HDE, New Smart("Loaded hours")},
            {&HDF, New Smart("Load/unload retry count")},
            {&HE0, New Smart("Load friction")},
            {&HE1, New Smart("Load/Unload cycle count")},
            {&HE2, New Smart("Load-in time")},
            {&HE3, New Smart("Torque amplification count")},
            {&HE4, New Smart("Power-off retract count")},
            {&HE6, New Smart("GMR head amplitude")},
            {&HE7, New Smart("Temperature")},
            {&HF0, New Smart("Head flying hours")},
            {&HFA, New Smart("Read error retry rate")}
        }
    
    End Class
    
    Public Class Smart
        Public ReadOnly Property HasData() As Boolean
            Get
                If Current = 0 AndAlso Worst = 0 AndAlso Threshold = 0 AndAlso Data = 0 Then
                    Return False
                End If
                Return True
            End Get
        End Property
        Public Property Attribute() As String
        Public Property Current() As Integer
        Public Property Worst() As Integer
        Public Property Threshold() As Integer
        Public Property Data() As Integer
        Public Property IsOK() As Boolean
    
        Public Sub New()
    
        End Sub
    
        Public Sub New(ByVal attributeName As String)
            Me.Attribute = attributeName
        End Sub
    End Class
    
    ' <summary>
    ' Tested against Crystal Disk Info 5.3.1 and HD Tune Pro 3.5 on 15 Feb 2013.
    ' Findings; I do not trust the individual smart register "OK" status reported back frm the drives.
    ' I have tested faulty drives and they return an OK status on nearly all applications except HD Tune. 
    ' After further research I see HD Tune is checking specific attribute values against their thresholds
    ' and and making a determination of their own (which is good) for whether the disk is in good condition or not.
    ' I recommend whoever uses this code to do the same. For example -->
    ' "Reallocated sector count" - the general threshold is 36, but even if 1 sector is reallocated I want to know about it and it should be flagged.   
    ' </summary>
    

    Friday, March 10, 2017 5:23 AM
  • Here a Microsoft freeware tool with which you can build that yourself

    https://www.microsoft.com/en-us/download/details.aspx?id=8572


    Success
    Cor

    Friday, March 10, 2017 8:17 AM
  • i want to get all information from my hard drive, for example i want know badsector,temperature etc

    so anyone can help me ???

    This should get you started, I found this here, converted to VB.NET and cleaned up the formatting.
    Requires a Form with a Button (BtnGo) and a Multiline TextBox(TXTResults)
    Also requires a reference to System.Management in Project, Properties,References.
    MUST be run as admin. I am NOT Llewellyn Kruger 

    Code:

    'Copyright(c) 2013, Llewellyn Kruger
    'All rights reserved.
    'Redistribution And use In source And binary forms, with Or without modification, are permitted provided that the following conditions are met
    'Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    'Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 
    'the following disclaimer in the documentation And/Or other materials provided with the distribution.
    'THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS And CONTRIBUTORS “AS IS” AND ANY EXPRESS Or IMPLIED WARRANTIES, 
    'INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES Of MERCHANTABILITY And FITNESS For A PARTICULAR PURPOSE ARE DISCLAIMED. 
    'In NO Event SHALL THE COPYRIGHT HOLDER Or CONTRIBUTORS BE LIABLE For ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 
    'Or CONSEQUENTIAL DAMAGES (INCLUDING, BUT Not LIMITED To, PROCUREMENT Of SUBSTITUTE GOODS Or SERVICES; LOSS Of USE, DATA,
    'Or PROFITS; Or BUSINESS INTERRUPTION) HOWEVER CAUSED And On ANY THEORY Of LIABILITY, WHETHER In CONTRACT, STRICT LIABILITY, 
    'Or TORT (INCLUDING NEGLIGENCE Or OTHERWISE) ARISING In ANY WAY OUT Of THE USE Of THIS SOFTWARE, EVEN If ADVISED Of THE POSSIBILITY Of SUCH DAMAGE. 
    'MUST BE RUN WITH ELEVATED PERMISSIONS
    'FORM WITH A BUTTON (BtnGo) and a MultiLine TextBox (TXTResults)
    Option Infer On
    Imports Microsoft.VisualBasic
    Imports System
    Imports System.Collections.Generic
    Imports System.Management '****** Add a reference to System.Management in Project,Properties,References ******
    
    Public Class Form1
        Private Sub BtnGo_Click(sender As Object, e As EventArgs) Handles BtnGo.Click
            Dim SB As New System.Text.StringBuilder
            Try
    
                ' retrieve list of drives on computer (this will return both HDD's and CDROM's and Virtual CDROM's)                    
                Dim dicDrives = New Dictionary(Of Integer, HDD)()
    
                Dim wdSearcher = New ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive")
    
                ' extract model and interface information
                Dim iDriveIndex As Integer = 0
                For Each drive As ManagementObject In wdSearcher.Get()
                    Dim hdd = New HDD()
                    hdd.Model = drive("Model").ToString().Trim()
                    hdd.Type = drive("InterfaceType").ToString().Trim()
                    dicDrives.Add(iDriveIndex, hdd)
                    iDriveIndex += 1
                Next drive
    
                Dim pmsearcher = New ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia")
    
                ' retrieve hdd serial number
                iDriveIndex = 0
                For Each drive As ManagementObject In pmsearcher.Get()
                    ' because all physical media will be returned we need to exit
                    ' after the hard drives serial info is extracted
                    If iDriveIndex >= dicDrives.Count Then
                        Exit For
                    End If
                    If (drive("SerialNumber")) Is Nothing Then
                        dicDrives(iDriveIndex).Serial = "None"
                    Else
                        dicDrives(iDriveIndex).Serial = drive("SerialNumber").ToString().Trim()
                    End If
    
                    'dicDrives(iDriveIndex).Serial = If(drive("SerialNumber") Is Nothing, "None", drive("SerialNumber").ToString().Trim())
                    iDriveIndex += 1
                Next drive
    
                ' get wmi access to hdd 
                Dim searcher = New ManagementObjectSearcher("Select * from Win32_DiskDrive")
                searcher.Scope = New ManagementScope("\root\wmi")
    
                ' check if SMART reports the drive is failing
                searcher.Query = New ObjectQuery("Select * from MSStorageDriver_FailurePredictStatus")
                iDriveIndex = 0
                For Each drive As ManagementObject In searcher.Get()
                    dicDrives(iDriveIndex).IsOK = DirectCast(drive.Properties("PredictFailure").Value, Boolean) = False
                    iDriveIndex += 1
                Next drive
    
                ' retrive attribute flags, value worste and vendor data information
                searcher.Query = New ObjectQuery("Select * from MSStorageDriver_FailurePredictData")
                iDriveIndex = 0
                For Each data As ManagementObject In searcher.Get()
                    Dim bytes() As Byte = DirectCast(data.Properties("VendorSpecific").Value, Byte())
                    For i As Integer = 0 To 29
                        Try
                            Dim id As Integer = bytes(i * 12 + 2)
    
                            Dim flags As Integer = bytes(i * 12 + 4) ' least significant status byte, +3 most significant byte, but not used so ignored.
                            'bool advisory = (flags & 0x1) == 0x0;
                            Dim failureImminent As Boolean = (flags And &H1) = &H1
                            'bool onlineDataCollection = (flags & 0x2) == 0x2;
    
                            Dim value As Integer = bytes(i * 12 + 5)
                            Dim worst As Integer = bytes(i * 12 + 6)
                            Dim vendordata As Integer = BitConverter.ToInt32(bytes, i * 12 + 7)
                            If id = 0 Then
                                Continue For
                            End If
    
                            Dim attr = dicDrives(iDriveIndex).Attributes(id)
                            attr.Current = value
                            attr.Worst = worst
                            attr.Data = vendordata
                            attr.IsOK = failureImminent = False
                        Catch
                            ' given key does not exist in attribute collection (attribute not in the dictionary of attributes)
                        End Try
                    Next i
                    iDriveIndex += 1
                Next data
    
                ' retreive threshold values foreach attribute
                searcher.Query = New ObjectQuery("Select * from MSStorageDriver_FailurePredictThresholds")
                iDriveIndex = 0
                For Each data As ManagementObject In searcher.Get()
                    Dim bytes() As Byte = DirectCast(data.Properties("VendorSpecific").Value, Byte())
                    For i As Integer = 0 To 29
                        Try
    
                            Dim id As Integer = bytes(i * 12 + 2)
                            Dim thresh As Integer = bytes(i * 12 + 3)
                            If id = 0 Then
                                Continue For
                            End If
    
                            Dim attr = dicDrives(iDriveIndex).Attributes(id)
                            attr.Threshold = thresh
                        Catch
                            ' given key does not exist in attribute collection (attribute not in the dictionary of attributes)
                        End Try
                    Next i
    
                    iDriveIndex += 1
                Next data
    
                For Each drive In dicDrives
                    SB.AppendLine("-----------------------------------------------------")
                    SB.AppendLine("DRIVE : " & drive.Value.Serial & " - " & drive.Value.Model & " - " & drive.Value.Type & " - " & drive.Value.IsOK.ToString)
                    SB.AppendLine("-----------------------------------------------------")
                    SB.AppendLine("")
    
                    SB.AppendLine("ID                                      Current   Worst     Threshold Data      Status")
                    For Each attr In drive.Value.Attributes
                        If attr.Value.HasData Then
                            SB.AppendLine(attr.Value.Attribute.PadRight(40, " ") & attr.Value.Current.ToString.PadRight(10) &
                                          attr.Value.Worst.ToString.PadRight(10) & attr.Value.Threshold.ToString.PadRight(10) & attr.Value.Data.ToString.PadRight(10) & attr.Value.IsOK.ToString)
                        End If
                    Next attr
                    SB.AppendLine()
                    SB.AppendLine()
                    SB.AppendLine()
                Next drive
    
                Console.ReadLine()
            Catch ex As ManagementException
                SB.AppendLine("An error occurred while querying for WMI data: " & ex.Message)
            End Try
            TXTResults.Text = SB.ToString
        End Sub
    End Class
    
    
    Public Class HDD
    
        Public Property Index() As Integer
        Public Property IsOK() As Boolean
        Public Property Model() As String
        Public Property Type() As String
        Public Property Serial() As String
        Public Attributes As New Dictionary(Of Integer, Smart)() From {
            {&H0, New Smart("Invalid")},
            {&H1, New Smart("Raw read error rate")},
            {&H2, New Smart("Throughput performance")},
            {&H3, New Smart("Spinup time")},
            {&H4, New Smart("Start/Stop count")},
            {&H5, New Smart("Reallocated sector count")},
            {&H6, New Smart("Read channel margin")},
            {&H7, New Smart("Seek error rate")},
            {&H8, New Smart("Seek timer performance")},
            {&H9, New Smart("Power-on hours count")},
            {&HA, New Smart("Spinup retry count")},
            {&HB, New Smart("Calibration retry count")},
            {&HC, New Smart("Power cycle count")},
            {&HD, New Smart("Soft read error rate")},
            {&HB8, New Smart("End-to-End error")},
            {&HBE, New Smart("Airflow Temperature")},
            {&HBF, New Smart("G-sense error rate")},
            {&HC0, New Smart("Power-off retract count")},
            {&HC1, New Smart("Load/Unload cycle count")},
            {&HC2, New Smart("HDD temperature")},
            {&HC3, New Smart("Hardware ECC recovered")},
            {&HC4, New Smart("Reallocation count")},
            {&HC5, New Smart("Current pending sector count")},
            {&HC6, New Smart("Offline scan uncorrectable count")},
            {&HC7, New Smart("UDMA CRC error rate")},
            {&HC8, New Smart("Write error rate")},
            {&HC9, New Smart("Soft read error rate")},
            {&HCA, New Smart("Data Address Mark errors")},
            {&HCB, New Smart("Run out cancel")},
            {&HCC, New Smart("Soft ECC correction")},
            {&HCD, New Smart("Thermal asperity rate (TAR)")},
            {&HCE, New Smart("Flying height")},
            {&HCF, New Smart("Spin high current")},
            {&HD0, New Smart("Spin buzz")},
            {&HD1, New Smart("Offline seek performance")},
            {&HDC, New Smart("Disk shift")},
            {&HDD, New Smart("G-sense error rate")},
            {&HDE, New Smart("Loaded hours")},
            {&HDF, New Smart("Load/unload retry count")},
            {&HE0, New Smart("Load friction")},
            {&HE1, New Smart("Load/Unload cycle count")},
            {&HE2, New Smart("Load-in time")},
            {&HE3, New Smart("Torque amplification count")},
            {&HE4, New Smart("Power-off retract count")},
            {&HE6, New Smart("GMR head amplitude")},
            {&HE7, New Smart("Temperature")},
            {&HF0, New Smart("Head flying hours")},
            {&HFA, New Smart("Read error retry rate")}
        }
    
    End Class
    
    Public Class Smart
        Public ReadOnly Property HasData() As Boolean
            Get
                If Current = 0 AndAlso Worst = 0 AndAlso Threshold = 0 AndAlso Data = 0 Then
                    Return False
                End If
                Return True
            End Get
        End Property
        Public Property Attribute() As String
        Public Property Current() As Integer
        Public Property Worst() As Integer
        Public Property Threshold() As Integer
        Public Property Data() As Integer
        Public Property IsOK() As Boolean
    
        Public Sub New()
    
        End Sub
    
        Public Sub New(ByVal attributeName As String)
            Me.Attribute = attributeName
        End Sub
    End Class
    
    ' <summary>
    ' Tested against Crystal Disk Info 5.3.1 and HD Tune Pro 3.5 on 15 Feb 2013.
    ' Findings; I do not trust the individual smart register "OK" status reported back frm the drives.
    ' I have tested faulty drives and they return an OK status on nearly all applications except HD Tune. 
    ' After further research I see HD Tune is checking specific attribute values against their thresholds
    ' and and making a determination of their own (which is good) for whether the disk is in good condition or not.
    ' I recommend whoever uses this code to do the same. For example -->
    ' "Reallocated sector count" - the general threshold is 36, but even if 1 sector is reallocated I want to know about it and it should be flagged.   
    ' </summary>

    can i add color like in hdd tune for example yellow is warning

    Monday, July 10, 2017 4:31 AM
  • can i add color like in hdd tune for example yellow is warning

    A textbox does not support multiple text colors.  You can change the text box to a rich text box. See:
    https://stackoverflow.com/questions/1683779/simple-text-color-in-rich-text-box

    If you are adjusting the text as you create it, it would probably be most convenient to update the RTB as you go, rather than trying to parse the string and then do one big update at the end.

    Monday, July 10, 2017 4:45 AM
  • can i add color like in hdd tune for example yellow is warning

    A textbox does not support multiple text colors.  You can change the text box to a rich text box. See:

    If you are adjusting the text as you create it, it would probably be most convenient to update the RTB as you go, rather than trying to parse the string and then do one big update at the end.

    and how i can know warning,error or not like in hdtune, In my program it shows ok status but in hd tune show yellow block and warning status how i can do like that
    Monday, July 10, 2017 6:27 AM
  • and how i can know warning,error or not like in hdtune

    You consult the specifications for the device that you are reporting on, and you discover what the acceptable parameters are for the condition that is being reported.  It is different for each one, and often different between different manufacturers.

    In my program it shows ok status but in hd tune show yellow block and warning status how i can do like that

    Use the example at the site referred to above (or at many other sites that show similar information).  Develop a small test application with arbitrary text as a demonstration of how to select regions of the RTB for setting the color.  Then construct your text strings according to the tests for OK/Warning/Error values determined from the information for the device parameter, append the text to the RTB text property, select the relevant portion of the RTB text string using selection start and selection length, and color it. 

    Monday, July 10, 2017 6:37 AM
  • Why the F2 (Total LBAs Read) vaule is a negative number, the Wikipedia said that "Some S.M.A.R.T. utilities will report a negative number for the raw value since in reality it has 48 bits rather than 32."

    How to convert to the right value?

    Friday, November 9, 2018 3:20 AM