Beginners tend to ask how they can write a program that displays the processor model of a computer. There are a few different methods that can be used for this. You can call the SET command or you can query the registry. To call the SET command, connect to the output from a process and find the processor information in the output data.
'Load processor information.
Dim ProcessorIdentifier = ""
Dim Ps = New ProcessStartInfo("cmd", "/c set")
Dim Raw As String
Ps.RedirectStandardOutput = True
Ps.UseShellExecute = False
Using P = Process.Start(Ps)
P.WaitForExit()
Raw = P.StandardOutput.ReadToEnd()
End Using
Dim Rows() = Raw.Split(ControlChars.CrLf.ToCharArray(),
StringSplitOptions.RemoveEmptyEntries)
For Each Row As String In Rows
If Row.StartsWith("PROCESSOR_IDENTIFIER=") Then
ProcessorIdentifier = Row.Substring(21)
Exit For
End If
Next
'Display processor information.
MessageBox.Show(ProcessorIdentifier)
Another method is to check the computer registry in HKEY_LOCAL_MACHINE at HARDWARE\DESCRIPTION\System\CentralProcessor\0. The key is Identifier.
'Load processor information.
Dim ProcessorIdentifier = ""
Dim Hardware = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("HARDWARE")
If Not Hardware Is Nothing Then
Dim CP = Hardware.OpenSubKey("DESCRIPTION\System\CentralProcessor\0")
ProcessorIdentifier = If(Not CP Is Nothing,
CP.GetValue("Identifier").ToString(), "")
End If
'Display processor information.
MessageBox.Show(ProcessorIdentifier)

Leave a Reply