public class DeviceMonitor
{
static readonly PerformanceCounter cpuCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total");
static readonly PerformanceCounter ramCounter = new PerformanceCounter("Memory", "Available MBytes");
static readonly PerformanceCounter uptime = new PerformanceCounter("System", "System Up Time");
public static bool GetInternetAvilable()
{
bool networkUp = System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable();
return networkUp;
}
public static TimeSpan GetSystemUpTime()
{
uptime.NextValue();
TimeSpan ts = TimeSpan.FromSeconds(uptime.NextValue());
return ts;
}
public static string Ge
c#获取电脑运行状态(cpu,内存,网络,系统运行时间)
最新推荐文章于 2023-02-02 11:20:51 发布