J
[email protected] said:Hi
Here is the code. Watch out for line wraps
VB
Class WMClassLib_VB
Function CpuID()
Dim oWMI, oCpu
oWMI = GetObject("winmgmts:")
For Each oCpu In oWMI.InstancesOf
("Win32_Processor")
Console.WriteLine("CPU: " & oCpu.ProcessorID)
Next
End Function
End Class
C#(Add System.Management to References)
using System;
using System.Text;
using System.Runtime.InteropServices;
using System.Management;
namespace CPUIDUsingWMI_CSharpClassLib
{
public class WMClassLib_CSharp
{
public string GetCPUId()
{
string cpuInfo = String.Empty;
string temp=String.Empty;
ManagementClass mc = new ManagementClass
("Win32_Processor");
ManagementObjectCollection moc = mc.GetInstances();
foreach(ManagementObject mo in moc)
{
if(cpuInfo==String.Empty)
{// only return cpuInfo from first CPU
cpuInfo = mo.Properties["ProcessorId"].Value.ToString
();
}
}
return cpuInfo;
}
}
}
hth
regards,
sr-----Original Message-----
.