C#を使用して、現在のCPUアクティビティ、使用されているRAM、およびディスクアクティビティを3つの小さなパーセンテージタイプのバーとして表示する小さなWPFウィジェットを作成しました。これには次のPerformanceCountersを使用しました:(diskCounterPerformanceCounterは、現在の合計ディスクアクティビティを1秒あたりのバイト数で返します)
private void InitialisePerformanceCounters()
{
cpuCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total", true);
totalRam = (int)(new Microsoft.VisualBasic.Devices.ComputerInfo().TotalPhysicalMemory / 1024 / 1024);
ramCounter = new PerformanceCounter("Memory", "Available MBytes");
diskCounter = new PerformanceCounter("PhysicalDisk", "Disk Bytes/sec", "_Total", true);
}
問題は、使用可能なパーセンテージを計算するために使用可能なRAMの合計を取得する方法を発見したにもかかわらず、ディスクの「理論上の」最大データ転送速度を読み取る方法を見つけることができないことです。使用されるディスク転送速度のパーセンテージを計算するためにこれが必要です。どんな助けでも大歓迎です。