简单的实现代码:
Public Class Form1 Private PerCounter As System.Diagnostics.PerformanceCounter Private Sub Form1_Load(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles MyBase.Load PerCounter = New System.Diagnostics.PerformanceCounter PerCounter.CategoryName = "Processor" PerCounter.CounterName = "% Processor Time" PerCounter.InstanceName = "_Total" Dim nutzram As Double nutzram = (My.Computer.Info.TotalPhysicalMemory - My.Computer.Info.AvailablePhysicalMemory) / 1048576 / 1024 Label2.Text = "RAM: " & nutzram.ToString("N") & " GB" Dim Prozent1 As Long Prozent1 = My.Computer.Info.AvailablePhysicalMemory * 100 Dim Prozentsatz As Long Prozentsatz = Val(Prozent1 / My.Computer.Info.TotalPhysicalMemory) ProgressBar2.Value = Prozentsatz Dim i As Integer = Integer.Parse(Format(PerCounter.NextValue,"##0")) ProgressBar1.Value = i Label1.Text = "cpu: " & i & " %" End Sub Private Sub Timer1_Tick(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles Timer1.Tick Dim nutzram As Double nutzram = (My.Computer.Info.TotalPhysicalMemory - My.Computer.Info.AvailablePhysicalMemory) / 1048576 / 1024 Label2.Text = "RAM: " & nutzram.ToString("N") & " GB" Dim Prozent1 As Long Prozent1 = My.Computer.Info.AvailablePhysicalMemory * 100 Dim Prozentsatz As Long Prozentsatz = Val(Prozent1 / My.Computer.Info.TotalPhysicalMemory) ProgressBar2.Value = Prozentsatz Dim i As Integer = Integer.Parse(Format(PerCounter.NextValue,"##0")) ProgressBar1.Value = i Label1.Text = "cpu: " & i & " %" End Sub End Class原文链接:https://www.f2er.com/vb/258782.html