Windows 下获取硬盘序列号
只获取序列号
以下任意一条命令都可以:
wmic diskdrive get serialnumber
wmic path win32_physicalmedia get SerialNumber
wmic path Win32_DiskDrive get SerialNumber
运行结果:
**注意**:windows 7 下获取的序列号格式可能和 Windows 10 下的不一样
获取硬盘的更多信息
wmic diskdrive get Name, Manufacturer, Model, InterfaceType, MediaType, SerialNumber
相关的字段(属性)可以查看微软官方文档
C# 中获取硬盘信息的代码
需要引用 System.Management 库
public static List<String> get_serial_number() { List<String> serial_number_list = new List<String>(); try { ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive"); foreach (ManagementObject info in searcher.Get()) { string interface_type = info["InterfaceType"].ToString().Trim(); string serial_number = info["SerialNumber"].ToString().Trim(); serial_number_list.Add(serial_number); } } catch (Exception e) { } return serial_number_list; }
参考:https://winaero.com/blog/find-hard-disk-serial-number-windows-10/