如何在 C# 中获取 U 盘或 USB 硬盘的内部序列号?
最佳答案
试试这个:
// add a reference to the System.Management assembly and
// import the System.Management namespace at the top in your "using" statement.
// Then in a method, or on a button click:
ManagementObjectSearcher theSearcher = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive WHERE InterfaceType='USB'");
foreach (ManagementObject currentObject in theSearcher.Get())
{
ManagementObject theSerialNumberObjectQuery = new ManagementObject("Win32_PhysicalMedia.Tag='" + currentObject["DeviceID"] + "'");
MessageBox.Show(theSerialNumberObjectQuery["SerialNumber"].ToString());
}
关于c# - 如何在C#中获取USB-Stick的序列号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/450009/