Search code examples
vb.netcpucpu-speed

Get CPU Name, Architecture and Clock Speed in VB


How do I find my CPU Name, Architecture and Clock Speed as a string in Visual Basic? I want it to display like it does in System Properties: Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz

I need the answer in VB.net. I have found other answers in C#, C++, C and Java.


Solution

  • VBA cannot do that directly, but you can invoke the Windows Management Interface.

    Please see the information from http://www.asap-utilities.com/excel-tips-detail.php?categorie=9&m=78 (copied below)


    Sub ProcessorSpeed()
    ' shows the processor name and speed of the computer
      Dim MyOBJ                              As Object
      Dim cpu                                As Object
      Set MyOBJ = GetObject("WinMgmts:").instancesof("Win32_Processor")
      For Each cpu In MyOBJ
            MsgBox(cpu.Name.ToString + " " + cpu.CurrentClockSpeed.ToString + " Mhz", vbInformation)
      Next
    End Sub