.net 部分项目中,需要检测电脑的内存使用情况,方便提醒
需要引用系统自带的Microsoft.VisualBasic.Devices库.
具体代码:
Computer myComputer = new Computer();
zone.Text = FormatFileSize(myComputer.Info.TotalPhysicalMemory);
ztwo.Text = FormatFileSize(myComputer.Info.AvailablePhysicalMemory );
zthere.Text = FormatFileSize(myComputer.Info.TotalVirtualMemory);
zfour.Text = FormatFileSize(myComputer.Info.AvailableVirtualMemory);
实现效果: