当前位置:   article > 正文

检测指定进程的CPU和内存占用情况_vb.net如何获取当前进程的cpu

vb.net如何获取当前进程的cpu
    '检测指定进程的CPU和内存占用情况
    'vs2019 vb.net 
    Dim Name = Process.GetCurrentProcess().ProcessName
    Dim cpuCounter = New PerformanceCounter("Process", "% Processor Time", Name)
    Dim ramCounter = New PerformanceCounter("Process", "Working Set", Name)
    Dim cpu = cpuCounter.NextValue().ToString("p1")
    Dim ram = (ramCounter.NextValue() / 1024 / 1024 / 2).ToString("f1")
    Debug.WriteLine(Name & ", " & cpu & ", " & ram)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号