如何獲得cpu使用百分比以顯示在表單上的標籤上?如何獲取CPU使用率?
4
A
回答
1
看吧:How to get the CPU Usage C#
應該很容易轉換爲VB.Net
1
你至少可以使用WMI API做它在.NET。 WMI可以讓你得到了一組Windows管理類型的數據,如CPU使用率,hardare規格等
http://www.aspfree.com/c/a/VB.NET/WMI-Programming-with-Visual-BasicNET-What-is-the-WQL/
19
Import Namespace System.Diagnostics
' ...
Dim cpu as New PerformanceCounter()
With cpu
.CategoryName = "Processor"
.CounterName = "% Processor Time"
.InstanceName = "_Total"
End With
' ...
myLabel.Text = cpu.NextValue()
+0
thanx幫助 – Mark 2011-04-11 23:10:16
2
codekaizen說:
Import Namespace System.Diagnostics
Dim cpu as New PerformanceCounter()
With cpu
.CategoryName = "Processor"
.CounterName = "% Processor Time"
.InstanceName = "_Total"
End With
myLabel.Text = cpu.NextValue()
如果你結束了「0」(可能是因爲你剛剛創建了PerformanceCounter,然後直接使用它) 由於PerformanceCounter需要一些工作時間,所以需要添加2行:
System.Threading.Thread.Sleep(1000)
myLabel.Text= cpu.NextValue
爲了避免睡眠,您可能需要在Class中聲明PerformanceCounter而不是Sub/Function,並在窗體加載事件中設置probs。
相關問題
- 1. 如何獲得Qt的CPU使用率
- 2. 如何使用C++在WMI中獲取CPU使用率?
- 3. 獲取CPU使用率提示
- 4. 通過golang獲取CPU使用率
- 5. 如何在Flash中獲取CPU使用率?
- 6. 從閃存中獲取CPU使用率和CPU內存消耗?
- 7. CPU使用率( 「」)
- 8. 獲取CPU利用率信息
- 9. MongoDB的查詢來獲取CPU使用率使用MongoDB的
- 10. 使用Java從Azure API獲取CPU使用率
- 11. 如何通過iphone上的API獲取CPU利用率信息?
- 12. 如何在Linux中獲取特定進程的CPU利用率
- 13. Websphere CPU使用率
- 14. CentOS CPU使用率
- 15. 如何最大化WebJob CPU使用率
- 16. 如何降低CruiseControl.NET的CPU使用率?
- 17. 如何減少CPU使用率?
- 18. 如何增加mysqld-nt CPU使用率
- 19. 如何降低ffmpeg的CPU使用率?
- 20. 如何限制FFMpeg CPU使用率?
- 21. 如何在Linux上獲得整體CPU使用率(例如57%)
- 22. 使用批處理腳本獲取CPU利用率百分比
- 23. 獲取當前進程的CPU使用率用C
- 24. 如何從代碼獲取Silverlight應用程序的CPU使用率?
- 25. 如何獲得每個線程的CPU使用率在Mac OSX
- 26. 如何獲得超過2個核心的CPU使用率?
- 27. 如何在jsp上獲得CPU使用率
- 28. 如何獲得C中的CPU使用率?
- 29. 如何獲得Linux中的總CPU使用率(C++)
- 30. 如何獲得iPhone/iPad的CPU使用率?
VB.NET或Visual Basic 6.0? – 2009-04-28 06:15:41