vb.net CPU & RAM 显示程序
2013-06-17 21:12
351 查看
简单的实现代码:
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
相关文章推荐
- VB.Net Winform程序的简单打包和部署--<机房收费系统>
- vb.net 四舍五入& 格式化显示
- [VB.NET]如何在程序启动后让视图正好显示datagridview的最后一行?
- DOS程序显示"Invalid keyboard code specified"的解决办法
- 使用vb.net获取程序的相对路径及其根目录
- VB.NET编程之托盘程序篇
- 通过程序 VB.Net 或 C# 读取文本文件行数
- [NET]VB.NET启动并监测外部程序
- <机房收费系统>重构至今之感(VB.NET)
- asp.net 程序性能优化的七个方面 (c#(或vb.net)程序改进)
- VB.NET制作外接程序的一个示例
- VB.Net语言方面的改进(&#36681;)
- VB.NET中串口通讯延时程序
- 用vb.net实现写字板程序报告(二)
- VB.NET关闭窗体时最小化(附带解决.NET程序导致XP无法关机重启的问题)
- 我与VB.net再次重逢,最简单的一个小程序
- 解决:VB.NET程序中 datagridview 多次绑定出现 的“不能在数据绑定的 DataGridView 控件上设置 ColumnCount
- C#(VB.NET)操作Windows自带的防火墙 之 还原默认设置、阻止程序通知
- VB.net 程序需连接Oralce数据库查询 日志提示“数据类型不被支持”
- VB.NET启动外部程序