Hi to everybody,
is it there a manner to get the state of hard disk to make a visual state indicator like a led??Cross-Platform??? win-mac-linux??
best regards,
Lestroso
how to get the state of hardisk to make visual led state?
- RSBasic
- Moderator
- Posts: 1218
- Joined: Thu Dec 31, 2009 11:05 pm
- Location: Gernsbach (Germany)
- Contact:
Re: how to get the state of hardisk to make visual led state
I only have one code for Windows:
I can't test just now.
Code: Select all
;Autor: kvitaliy, Falko, mk-soft, RSBasic
;http://www.purebasic.fr/german/viewtopic.php?p=298062#p298062
EnableExplicit
#IOCTL_DISK_PERFORMANCE = $70020
Structure DISK_PERFORMANCE
BytesRead.q
BytesWritten.q
ReadTime.q
WriteTime.q
IdleTime.q
ReadCount.l
WriteCount.l
QueueDepth.l
SplitCount.l
QueryTime.l
StorageDeviceNumber.l
StorageManagerName.l[8]
EndStructure
Define Event
Define hdh
Define lBytesReturned
Define OldReadTime.q
Define OldWriteTime.q
Define DISK_PERFORMANCE.DISK_PERFORMANCE
CreateImage(1, 16, 16, 32, RGB(255, 255, 255));Idle (weiß)
CreateImage(2, 16, 16, 32, RGB(0, 255, 0));Lesezugriff (grün)
CreateImage(3, 16, 16, 32, RGB(255, 0, 0));Schreibzugriff (rot)
If OpenWindow(0, 0, 0, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
;"PhysicalDrive1" ggf. anpassen
hdh = CreateFile_("\\.\PhysicalDrive1", 0, 0, 0, #OPEN_EXISTING, 0, 0)
If hdh = #INVALID_HANDLE_VALUE
End
EndIf
AddSysTrayIcon(1, WindowID(0), ImageID(1))
Repeat
Event = WaitWindowEvent(10)
DeviceIoControl_(hdh, #IOCTL_DISK_PERFORMANCE, 0, 0, @DISK_PERFORMANCE, SizeOf(DISK_PERFORMANCE), @lBytesReturned, 0)
;Schreibzugriff überprüfen
If PeekQ(@DISK_PERFORMANCE\WriteTime)<>OldWriteTime
OldWriteTime = PeekQ(@DISK_PERFORMANCE\WriteTime)
ChangeSysTrayIcon(1, ImageID(3))
Else
;Lesezugriff überprüfen
If PeekQ(@DISK_PERFORMANCE\ReadTime) <> OldReadTime
OldReadTime = PeekQ(@DISK_PERFORMANCE\ReadTime)
ChangeSysTrayIcon(1, ImageID(2))
Else
ChangeSysTrayIcon(1, ImageID(1))
EndIf
EndIf
Select Event
Case #PB_Event_CloseWindow
End
EndSelect
ForEver
EndIf
Re: how to get the state of hardisk to make visual led state
THANKS A LOT RSBASIC!
I have treyed on mac but don't works....i tryed on windows..but it don't works too..i thank you a lot for your code...i appriciate so much...can somebody can help me with a little working code?? .Best regards,
Lestroso
I have treyed on mac but don't works....i tryed on windows..but it don't works too..i thank you a lot for your code...i appriciate so much...can somebody can help me with a little working code?? .Best regards,
Lestroso