I can get the HDD serial number using ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia")
, and for each ManagementObject
from the result set I can read the serial number.
I am interested in another way of obtaining this information (without WMI) for IDE and SATA HDD, since I get mixed results with my current approach.
Edit - It seems that the only alternative is using DeviceIoControl
. Can anyone point me to a full example of C# code invoking DeviceIoControl
? I have no experience using P/Invoke
.
Environment: C# 2.0, Windows 2000 or newer.