简体   繁体   English

如何在C#4.0中区分硬盘模型

[英]How to Differentiate Hard Drive models in C# 4.0

I am currently using a WMI query to return the manufacturer name of all hard disks connected to a computer. 我目前正在使用WMI查询来返回连接到计算机的所有硬盘的制造商名称。 Unfortunately this doesn't specifically return "Intel" or "Western Digital" so I am using string.Contains() to compare who the manufacturer is. 不幸的是,这没有专门返回“ Intel”或“ Western Digital”,因此我使用string.Contains()来比较制造商是谁。 My code in simple form is: 我的简单形式的代码是:

        //*** Declare Management Class
        ManagementClass clsMgtClass = new ManagementClass("Win32_DiskDrive");
        ManagementObjectCollection colMgtObjCol = clsMgtClass.GetInstances();

        //*** Loop Over Objects

        foreach (ManagementObject objMgtObj in colMgtObjCol)
        {
            MessageBox.Show(objMgtObj.Properties["Manufacturer"].Value.ToString());
        }

This works maybe 60% of the time, because it relies on the WMI to return the whole name. 这可能在60%的时间内有效,因为它依靠WMI返回全名。 So for example my hard drive is returned as "SanDisk SDSSDX240GG25 ATA Device" which is fine because I can locate "SanDisk" quite easily. 因此,例如,我的硬盘驱动器返回为“ SanDisk SDSSDX240GG25 ATA设备”,这很好,因为我可以很容易地找到“ SanDisk”。 Likewise, Western Digital products will show up as "WD3000USB" or something like that, where I can clearly find "WD". 同样,Western Digital产品将显示为“ WD3000USB”或类似名称,在这里我可以清楚地找到“ WD”。 However on another computer using a Seagate drive, it has SE1000GXB blah blah and doesn't have any real indication of the manufacturer. 但是,在另一台使用Seagate驱动器的计算机上,它的名称为SE1000GXB等等,没有任何实际的制造商指示。 So my question is, how could I reliably find out the hard drive manufacturer, and be able to easily differentiate between manufacturers without having to go to all the trouble of querying model numbers through a google script or database. 因此,我的问题是,我如何才能可靠地找到硬盘驱动器制造商,并且能够轻松区分制造商,而不必费心通过Google脚本或数据库查询型号。 Thanks. 谢谢。 Another edit: using the member "Caption", it will return the examples above. 另一个编辑:使用成员“标题”,它将返回上面的示例。 Using the member "Manufacturer" will simply return "(Standard Disk Drives)" 使用成员“ Manufacturer”将仅返回“(标准磁盘驱动器)”

ST - seagate ST-希捷

You could download a list of model number prefixes from each of the now merged hard disk companies and make a table out of the models, this table could contain the actual capacities as well if you wished. 您可以从每个现在合并的硬盘公司下载型号前缀列表,并从这些型号中创建一个表格,如果需要,该表格也可以包含实际容量。

Model numbers typically have enough information in them, serial numbers on disk devices after 1986 typically contain model information in them. 型号中通常包含足够的信息,1986年以后的磁盘设备上的序列号中通常包含型号信息。

Bottom line, you may have to create a table to lookup the information in a human friendly way. 最重要的是,您可能必须创建一个表以人类友好的方式查找信息。

http://www.robvanderwoude.com/files/listhdds_2k.txt http://www.robvanderwoude.com/files/listhdds_2k.txt

this will help you know what merged http://en.wikipedia.org/wiki/List_of_defunct_hard_disk_manufacturers 这将帮助您了解合并的内容http://en.wikipedia.org/wiki/List_of_defunct_hard_disk_manufacturers

here's a batch file for windows http://www.robvanderwoude.com/sourcecode.php?src=listhdds_2k 这是Windows的批处理文件http://www.robvanderwoude.com/sourcecode.php?src=listhdds_2k

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM