Here is the code I have come up with. The idea is to set an icon into the tray depending on its current status idle/read/write/read+write. The only problem is that it fails. Any and all help appreciated.
#include <Process.au3>
;#Include <Timers.au3>
Global $NID[444], $Ret, $nReturn
Global $ORC=0, $OWC=0, $DP[88]
main()
Func main()
ProcessSetPriority("HHD_Monitor.au3", 4)
$PID = DllCall("kernel32.dll", "handle", "GetCurrentProcessId")
; Run, diskperf.exe -y ; Execute it once to enable Disk Performance monitoring.
; DISK_PERFORMANCE
$hDrv = DllCall("kernel32.dll", "ptr", "CreateFile", "Str", "\\.\PhysicalDrive0", "uint", 0, "uint", 3, "uint", 0, "uint", 3, "uint", 0, "uint", 0)
While 1
;_Timer_SetTimer(HDD_Monitor)
;HDD_Monitor:
$Ret = DllCall("kernel32.dll", "int", "DeviceIoControl", "uint", 0x70020, "uint", DllStructGetPtr($DP), "uint", 88, "uint_ptr", $nReturn, "uint", 0)
$NRC = $DP[40] ;NRC:=NumGet(DP,40),
$NWC = $DP[44] ;NWC:=NumGet(DP,44),
$RC = $NRC - $ORC ;RC:=NRC-ORC,
$WC = $NWC - $OWC ;WC:=NWC-OWC,
$ORC = $NRC ;
$ORC = $NRC ;ORC:=NRC,
$OWC = $NWC ;OWC:=NWC
If $RC=0 And $WC=0 Then
; $IC=1
TraySetIcon("0.icon")
ElseIf $RC<>0 And $WC=0 Then
; $IC=2
TraySetIcon("1.icon")
ElseIf $RC=0 And $WC<>0 Then
; $IC=3
TraySetIcon("2.icon")
ElseIf $RC<>0 and $WC<>0 Then
; $IC=4
TraySetIcon("3.icon")
EndIf
WEnd
EndFunc