windows - How to get ATAPI SMART Data according to disks using C#/.NET -


i want write application monitors status of disk or more disks in system.

i found can manage 1 disk via wmi "root/wmi" , msstoragedriver , query these actual values (data , threshold), followed below link - http://wutils.com/wmi/root/wmi/msstoragedriver_atapismartdata/ far, worked :-)

however, have not managed multiple disks until now. don't know how smart data according disks

could me resolve issue?

many thanks, quyen

i tried , succeed, share answers issue

  • get pnpdeviceid
  • get instancename of pnpdevice accordingly
  • get s.m.a.r.t data instancename

example code

public string   pnpdeviceid     {         set         {             this.m_pnpdeviceid = value;             this.instancename = null;             this.queryobjatapismartdata = null;              searcherpnpdeviceid = new managementobjectsearcher("root\\wmi", "select * mswmi_pnpdeviceid");             foreach (managementobject queryobj in searcherpnpdeviceid.get())             {                 if (queryobj["pnpdeviceid"] != null)                 {                     if (this.pnpdeviceid.toupper() == queryobj.getpropertyvalue("pnpdeviceid").tostring().toupper())                     {                         if (queryobj["instancename"] != null)                         {                             this.instancename = queryobj["instancename"].tostring();                             break;                         }                     }                 }             }              if (this.instancename != null)             {                  searcheratapismartdata = new managementobjectsearcher("root\\wmi", "select * msstoragedriver_atapismartdata");                 foreach (managementobject queryobj in searcheratapismartdata.get())                 {                     if (queryobj["instancename"] != null)                     {                         if (this.instancename.toupper() != queryobj.getpropertyvalue("instancename").tostring().toupper())                         {                             continue;                         }                     }                     this.queryobjatapismartdata  = queryobj;                     break;                 }         } 

}

after that, properties of queryobjatapismartdata

regards, quyen


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -