Skip to content

Instantly share code, notes, and snippets.

@xandout
Created January 13, 2014 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xandout/8405804 to your computer and use it in GitHub Desktop.
Save xandout/8405804 to your computer and use it in GitHub Desktop.
C# Small Hard Drive Class
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