Forum > General

Hard disk monitor

(1/4) > >>

Ericktux:
Good morning friends
I need your help, how can I get the use of the hard drive?

lucamar:
Can you be a little more specific about what you want to do?

If you just want to check the space used/free then use SysUtils.DiskSize(), SysUtils.DiskFree(), etc.

Ericktux:
hello friend, I was referring to get the use of the hard drive in activity, not the space, the work of the hard disk is what I need, I attach an example image.

Wallaby:
You might need to access performance counters.

It won't be easy...

rvk:
Just as a minimum project... Put a TTimer and an TMemo on a form and Interval of the TTimer to 500 with this event:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses contnrs, utilwmi; procedure TForm1.Timer1Timer(Sender: TObject);var  WMIResult: TFPObjectList;  I: integer;  PropNamesIndex: integer;  PropNames: array[0..1] of string = ('Name', 'PercentDiskTime');begin  WMIResult := GetWMIInfo('win32_perfformatteddata_perfdisk_physicaldisk',    PropNames, ''); // you could also do WHERE Name=''_Total'' as last param   Memo1.Clear;  for I := 0 to Pred(WMIResult.Count) do  begin    Memo1.Lines.Add('================================================');    for PropNamesIndex := Low(PropNames) to High(PropNames) do    begin      Memo1.Lines.Add(TStringList(WMIResult[i]).Names[PropNamesIndex] +        ' : ' + TStringList(WMIResult[i]).ValueFromIndex[PropNamesIndex]);    end;  end;  // Clean up  WMIResult.Free;end;
Get the utilwmi_v3_official.7z from the following topic and extract wmiutil.pas to your project directory.
https://forum.lazarus.freepascal.org/index.php/topic,24490.msg232201.html#msg232201

It's just to show you the wmi performance counters from all harddisks. If you add the WHERE Name='_Total' you get the average number (but maybe only take the avarage of the physical harddisks because the _Total has some extra). And you can also take other numbers from the wmi.

(not sure why the percentage sometimes comes above 100% when I run a benchmark on disk D)


--- Quote ---================================================
Name : 0 D:
PercentDiskTime : 96
================================================
Name : 1 C:
PercentDiskTime : 0
================================================
Name : 2
PercentDiskTime : 0
================================================
Name : 3
PercentDiskTime : 0
================================================
Name : 4
PercentDiskTime : 0
================================================
Name : 5
PercentDiskTime : 0
================================================
Name : 6
PercentDiskTime : 0
================================================
Name : 7
PercentDiskTime : 0
================================================
Name : _Total
PercentDiskTime : 12
--- End quote ---

Navigation

[0] Message Index

[#] Next page

Go to full version