Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check hard disk is Sata Device or it is IDE Device using c#

I have SATA Hard Disk, and I want to detect by C# windows form. I want to display that it is SATA or IDE drive. I am using following code but it always return IDE but its should be return SATA. So any one can help me to where I am wrong.

WqlObjectQuery q = new WqlObjectQuery("SELECT * FROM Win32_DiskDrive");
ManagementObjectSearcher res = new ManagementObjectSearcher(q);

foreach (ManagementObject o in res.Get())
 {
  string lblInterface= o["InterfaceType"].ToString();
 }
like image 899
Durgesh Pandey Avatar asked May 05 '16 11:05

Durgesh Pandey


1 Answers

According to the Win32_DiskDrive class documentation, the possible values for InterfaceType are:

SCSI

HDC

IDE

USB

1394

Hence, you would not see SATA.

However, Caption property may contain extra information about the drive. You can parse it to find whether it contains ATA or SCSI.

like image 195
Alex Avatar answered Oct 20 '22 19:10

Alex