在 VB 中获取 CPU 名称、体系结构和时钟速度

3 vb.net cpu cpu-speed

如何在 Visual Basic 中找到我的CPU Name,ArchitectureClock Speed作为字符串?我希望它像这样显示System PropertiesIntel(R) Core(TM) i5-3210M CPU @ 2.50GHz

我需要答案VB.net。我已经发现了在其他的答案C#C++CJava

小智 6

VBA 无法直接执行此操作,但您可以调用 Windows 管理界面。

请参阅http://www.asap-utilities.com/excel-tips-detail.php?categorie=9&m=78 中的信息(复制如下)


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
Run Code Online (Sandbox Code Playgroud)