PureBasic Forum
https://www.purebasic.fr/english/

how to get the state of hardisk to make visual led state?
https://www.purebasic.fr/english/viewtopic.php?f=13&t=72840
Page 1 of 1

Author:  LESTROSO [ Fri May 17, 2019 6:04 pm ]
Post subject:  how to get the state of hardisk to make visual led state?

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 :oops: :oops: :oops:

Author:  RSBasic [ Fri May 17, 2019 7:50 pm ]
Post subject:  Re: how to get the state of hardisk to make visual led state

I only have one code for Windows:
Code:
;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


I can't test just now.

Author:  LESTROSO [ Sat May 18, 2019 11:53 am ]
Post subject:  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
:) :) :)

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/