Gets the MAC address of the device's network card and the volume label of the hard disk
Code
using System;
using System.Management;
namespace netcard
{
///
///Read devices
///
P Ublic class Run
{
Private managementclass MC;
Private Managementobjectcollection MOC;
Private ManagementObject disk;
Public Run ()
{}
///
///Obtain the MAC address of the device's network card
///
public string getnetcardmacaddr ESS ()
{
MC = new ManagementClass ("Win32_NetworkAdapterConfiguration");
MOC = MC. GetInstances ();
String str = "";
foreach (ManagementObject mo in MoC)
{
if ((bool) mo["ipenabled"] = = True)
str = mo["MacAddress"]. ToString ();
}
return str;
///
///Obtain the volume label for the device hard disk
///
///
public string Getdiskvolumeserialnumber ()
{ br> mc = new ManagementClass ("Win32_NetworkAdapterConfiguration");
disk = new ManagementObject ("Win32_LogicalDisk.Deviceid=\ "C:\");
Disk. Get ();
return disk. GetPropertyValue ("VolumeSerialNumber"). ToString ();
}
}
}