Code
Using System;
Using System. Collections. Generic;
Using System. LINQ;
Using System. Management;
Using System. runtime. interopservices;
Using System. text;
Namespace Cai
{
Class Hardwareinfo
{
/// <Summary>
/// Machine name
/// </Summary>
/// <Returns> </returns>
Public String Gethostname ()
{
Return System. net. DNS. gethostname ();
}
/// <Summary>
/// CPU ID
/// </Summary>
/// <Returns> </returns>
Public String getcpuid ()
{
Try
{
Managementclass MC = New Managementclass ( " Win32_processor " );
Managementobjectcollection MoC = MC. getinstances ();
String strcpuid = Null ;
Foreach (Managementobject Mo In MOC)
{
Strcpuid = Mo. properties [ " Processorid " ]. Value. tostring ();
Break ;
}
Return Strcpuid;
}
Catch
{
Return "" ;
}
}
/// <Summary>
/// Read MAC address
/// </Summary>
/// <Returns> </returns>
Public String Getnetcardmacaddress ()
{
Managementclass MC;
Managementobjectcollection MOC;
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;
}
/// <Summary>
/// Reads the serial number of drive C.
/// </Summary>
/// <Returns> </returns>
Public String Getdiskvolumeserialnumber ()
{
Managementobject disk;
Disk = New Managementobject ( " Win32_logicaldisk.deviceid = \ " C :\ "" );
Disk. Get ();
Return Disk. getpropertyvalue ( " Volumeserialnumber " ). Tostring ();
}
}
}
Collect data from the network ..