Re: how to get cpu's id? by Ken

Ken
Tue Nov 18 21:17:14 CST 2003

Hi,

Add a reference to system.management.dll

Dim moReturn As Management.ManagementObjectCollection

Dim moSearch As Management.ManagementObjectSearcher

Dim mo As Management.ManagementObject

moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_Processor")

moReturn = moSearch.Get

For Each mo In moReturn

Debug.WriteLine(mo("Name"))

Debug.Indent()

Debug.WriteLine(mo("ProcessorID"))

Debug.Unindent()

Next

Ken
-----------------
"jay" <jay@scitc.3322.org> wrote in message
news:%23m3Y7JkrDHA.536@tk2msftngp13.phx.gbl...
>
>



how to get cpu's id? by rs_tiin

rs_tiin
Tue Nov 18 21:41:33 CST 2003

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-----
>
>
>.
>

Re: how to get cpu's id? by jay

jay
Tue Nov 18 22:22:11 CST 2003

Hi:
it's ok and i want to know any other method but wmi.
"rs_tiin@hotmail.com" <anonymous@discussions.microsoft.com> ????
news:059b01c3ae4f$0687ac30$a501280a@phx.gbl...
> 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-----
> >
> >
> >.
> >



Re: how to get cpu's id? by Wiktor

Wiktor
Wed Nov 19 03:28:46 CST 2003

> it's ok and i want to know any other method but wmi.

write a win32 library that makes use of cpuid instruction.