Created
January 13, 2014 18:49
-
-
Save xandout/8405804 to your computer and use it in GitHub Desktop.
C# Small Hard Drive Class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Management; | |
namespace TTR_RMM | |
{ | |
class HardDisk | |
{ | |
public String Model { get; set; } | |
public String Interface { get; set; } | |
public String Caption { get; set; } | |
public String Serial { get; set; } | |
public List<HardDisk> GetDrives() | |
{ | |
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive"); | |
List<HardDisk> hds = new List<HardDisk>(); | |
foreach (ManagementObject wmi_HD in searcher.Get()) | |
{ | |
HardDisk hd = new HardDisk(); | |
hd.Model = wmi_HD["Model"].ToString(); | |
hd.Interface = wmi_HD["InterfaceType"].ToString(); | |
hd.Caption = wmi_HD["Caption"].ToString(); | |
hd.Serial = wmi_HD.GetPropertyValue("SerialNumber").ToString(); | |
hds.Add(hd); | |
} | |
return hds; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment