C# Winform | Hardware Info | CPU ID, HDD, Mac, Serial
using System.Management
MSDN
Computer System Hardware Classes - Win32 apps
Computer System Hardware Classes In this article --> The Computer System Hardware category groups classes together that represent hardware related objects. Examples include input devices, hard disks, expansion cards, video devices, networking devices, and
docs.microsoft.com
위 이미지 예제 처럼 MSDN을 참고하여 ClassName과 Syntax를 함수 인자에 넣으면 원하는 하드웨어 정보를 얻을 수 있다.
TEST CODE
private void button1_Click(object sender, EventArgs e)
{
GetHardwareInfo("Win32_Processor", "Name");
GetHardwareInfo("Win32_Processor", "ProcessorID");
GetHardwareInfo("Win32_SystemBIOS", "PartComponent");
GetHardwareInfo("Win32_NetworkAdapter", "MACAddress");
GetHardwareInfo("Win32_DiskDrive", "SerialNumber");
}
private void GetHardwareInfo(string classname, string syntax)
{
ManagementObjectSearcher mos = new ManagementObjectSearcher("select * from " + classname);
foreach (ManagementObject Source in mos.Get())
{
Console.WriteLine(syntax + " - " + Source[syntax]);
}
}
|
cs |
output
'C# Winform' 카테고리의 다른 글
C# Winform | List Sort | ObservableCollection Sort (0) | 2020.07.03 |
---|---|
C# Winform | enum foreach (0) | 2020.05.06 |
C# Winform | DateTime Convert(Long To, TimeStamp to) (0) | 2020.04.28 |
C# Winform | properties settings 저장 (0) | 2020.03.05 |
C# Winform | cross thread - InvalidOperationException (0) | 2020.03.02 |