This article is a mirror article of machine translation, please click here to jump to the original article.

View: 20170|Reply: 0

[Console Program] C# gets the CPU and memory information of the system

[Copy link]
Posted on 11/4/2015 9:56:52 AM | | | |


  1. static void Main(string[] args)
  2.         {
  3.             PerformanceCounter pcCPULoad = new PerformanceCounter("Processor", "% Idle Time", "_Total");
  4.             ComputerInfo ci = new ComputerInfo();
  5.             //物理内存
  6.             ulong me = ci.TotalPhysicalMemory;
  7.             ulong av = ci.AvailablePhysicalMemory;
  8.             while (true)
  9.             {
  10.                 Thread.Sleep(500);
  11.                 Console.Write("CPU"+(100 - Math.Round(pcCPULoad.NextValue(), 0)));
  12.                 Console.Write("系统物理内存(M):" + ci.TotalPhysicalMemory / 1024 / 1024);
  13.                 Console.Write("系统虚拟内存(M):" + ci.TotalVirtualMemory / 1024 / 1024);
  14.                 Console.Write("可用物理内存(M):" + ci.AvailablePhysicalMemory / 1024 / 1024);
  15.                 Console.Write("可用虚拟内存(M):" + ci.AvailableVirtualMemory / 1024 / 1024);
  16.                 Console.WriteLine("");
  17.             }
  18.         }
Copy code






Previous:Jquery formats /Date(1356969600000)/ into the time format of the year, month, day
Next:Major bugs can be infinitely obtained with VIP wireless overlays for books
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com