processor id
-
guys i have tried many codes to find the processor id but i was not able to find it.............. does any one know how to code it in vb.net help me with a code........... plz...........
-
guys i have tried many codes to find the processor id but i was not able to find it.............. does any one know how to code it in vb.net help me with a code........... plz...........
The following code was tested using Visual Basic .NET 2012:
Option Strict Off Option Explicit Off
...
Dim strComputer As String = "." Dim objWMIService As Object = GetObject("winmgmts:" \_ & "{impersonationLevel=impersonate}!\\\\" & strComputer & "\\root\\cimv2") Dim colProcessors As Object = objWMIService.ExecQuery("Select \* from Win32\_Processor") For Each objProcessor In colProcessors Debug.WriteLine(" Manufacturer: " & objProcessor.Manufacturer) Debug.WriteLine(" Name: " & objProcessor.Name) Debug.WriteLine(" Description: " & objProcessor.Description) Debug.WriteLine(" ProcessorID: " & objProcessor.ProcessorID) Debug.WriteLine(" Architecture: " & objProcessor.Architecture) Debug.WriteLine(" AddressWidth: " & objProcessor.AddressWidth) Debug.WriteLine(" NumberOfCores: " & objProcessor.NumberOfCores) Debug.WriteLine(" DataWidth: " & objProcessor.DataWidth) Debug.WriteLine(" Family: " & objProcessor.Family) Debug.WriteLine(" MaximumClockSpeed: " & objProcessor.MaxClockSpeed) Next
Result on my computer:
Manufacturer: GenuineIntel
Name: Intel(R) Core(TM) i7-3820QM CPU @ 2.70GHz
Description: Intel64 Family 6 Model 58 Stepping 9
ProcessorID: BFAAFBCD002316D1
Architecture: 9
AddressWidth: 64
NumberOfCores: 4
DataWidth: 64
Family: 198
MaximumClockSpeed: 2694Source: Microsoft Visual Studio 2012 Help File for Win32_Processor[^]
-
The following code was tested using Visual Basic .NET 2012:
Option Strict Off Option Explicit Off
...
Dim strComputer As String = "." Dim objWMIService As Object = GetObject("winmgmts:" \_ & "{impersonationLevel=impersonate}!\\\\" & strComputer & "\\root\\cimv2") Dim colProcessors As Object = objWMIService.ExecQuery("Select \* from Win32\_Processor") For Each objProcessor In colProcessors Debug.WriteLine(" Manufacturer: " & objProcessor.Manufacturer) Debug.WriteLine(" Name: " & objProcessor.Name) Debug.WriteLine(" Description: " & objProcessor.Description) Debug.WriteLine(" ProcessorID: " & objProcessor.ProcessorID) Debug.WriteLine(" Architecture: " & objProcessor.Architecture) Debug.WriteLine(" AddressWidth: " & objProcessor.AddressWidth) Debug.WriteLine(" NumberOfCores: " & objProcessor.NumberOfCores) Debug.WriteLine(" DataWidth: " & objProcessor.DataWidth) Debug.WriteLine(" Family: " & objProcessor.Family) Debug.WriteLine(" MaximumClockSpeed: " & objProcessor.MaxClockSpeed) Next
Result on my computer:
Manufacturer: GenuineIntel
Name: Intel(R) Core(TM) i7-3820QM CPU @ 2.70GHz
Description: Intel64 Family 6 Model 58 Stepping 9
ProcessorID: BFAAFBCD002316D1
Architecture: 9
AddressWidth: 64
NumberOfCores: 4
DataWidth: 64
Family: 198
MaximumClockSpeed: 2694Source: Microsoft Visual Studio 2012 Help File for Win32_Processor[^]
-
The following code was tested using Visual Basic .NET 2012:
Option Strict Off Option Explicit Off
...
Dim strComputer As String = "." Dim objWMIService As Object = GetObject("winmgmts:" \_ & "{impersonationLevel=impersonate}!\\\\" & strComputer & "\\root\\cimv2") Dim colProcessors As Object = objWMIService.ExecQuery("Select \* from Win32\_Processor") For Each objProcessor In colProcessors Debug.WriteLine(" Manufacturer: " & objProcessor.Manufacturer) Debug.WriteLine(" Name: " & objProcessor.Name) Debug.WriteLine(" Description: " & objProcessor.Description) Debug.WriteLine(" ProcessorID: " & objProcessor.ProcessorID) Debug.WriteLine(" Architecture: " & objProcessor.Architecture) Debug.WriteLine(" AddressWidth: " & objProcessor.AddressWidth) Debug.WriteLine(" NumberOfCores: " & objProcessor.NumberOfCores) Debug.WriteLine(" DataWidth: " & objProcessor.DataWidth) Debug.WriteLine(" Family: " & objProcessor.Family) Debug.WriteLine(" MaximumClockSpeed: " & objProcessor.MaxClockSpeed) Next
Result on my computer:
Manufacturer: GenuineIntel
Name: Intel(R) Core(TM) i7-3820QM CPU @ 2.70GHz
Description: Intel64 Family 6 Model 58 Stepping 9
ProcessorID: BFAAFBCD002316D1
Architecture: 9
AddressWidth: 64
NumberOfCores: 4
DataWidth: 64
Family: 198
MaximumClockSpeed: 2694Source: Microsoft Visual Studio 2012 Help File for Win32_Processor[^]
Alternatively, if you want to do this the .NET way rather than the VBScript way, add a reference to the
System.Management
assembly, import the System.Management namespace[^], and use:Using searcher As New ManagementObjectSearcher("Select * from Win32_Processor")
Using processors As ManagementObjectCollection = searcher.Get()
For Each processor As ManagementObject In processors
Console.WriteLine("Manufacturer: {0}", processor("Manufacturer"))
Console.WriteLine("Name: {0}", processor("Name"))
Console.WriteLine("Description: {0}", processor("Description"))
Console.WriteLine("ProcessorID: {0}", processor("ProcessorID"))
Console.WriteLine("Architecture: {0}", processor("Architecture"))
Console.WriteLine("AddressWidth: {0}", processor("AddressWidth"))
Console.WriteLine("NumberOfCores: {0}", processor("NumberOfCores"))
Console.WriteLine("DataWidth: {0}", processor("DataWidth"))
Console.WriteLine("Family: {0}", processor("Family"))
Console.WriteLine("MaxClockSpeed: {0}", processor("MaxClockSpeed"))
Console.WriteLine()
Next
End Using
End Using
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
guys i have tried many codes to find the processor id but i was not able to find it.............. does any one know how to code it in vb.net help me with a code........... plz...........
Great response from Richard Deeming. I used that to create a version that does not require Option Strict Off and Option Explicit Off. Both can be set to on with this version:
Dim objSearcher As New ManagementObjectSearcher("Select \* from Win32\_Processor") Dim colProcessors As ManagementObjectCollection = objSearcher.Get For Each objProcessor As ManagementObject In colProcessors Debug.WriteLine("Manufacturer: " & DirectCast(objProcessor("Manufacturer"), String)) Debug.WriteLine("Name: " & DirectCast(objProcessor("Name"), String)) Debug.WriteLine("Description: " & DirectCast(objProcessor("Description"), String)) Debug.WriteLine("ProcessorID: " & DirectCast(objProcessor("ProcessorID"), String)) Debug.WriteLine("Architecture: " & CStr(objProcessor("Architecture"))) Debug.WriteLine("AddressWidth: " & CStr(objProcessor("AddressWidth"))) Debug.WriteLine("NumberOfCores: " & CStr(objProcessor("NumberOfCores"))) Debug.WriteLine("DataWidth: " & CStr(objProcessor("DataWidth"))) Debug.WriteLine("Family: " & CStr(objProcessor("Family"))) Debug.WriteLine("MaximumClockSpeed: " & CStr(objProcessor("MaxClockSpeed"))) Next