It is currently Thu Nov 14, 2019 11:03 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: how to get the state of hardisk to make visual led state?
PostPosted: Fri May 17, 2019 6:04 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Nov 03, 2005 12:30 pm
Posts: 117
Location: Italy
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:


Top
 Profile  
Reply with quote  
 Post subject: Re: how to get the state of hardisk to make visual led state
PostPosted: Fri May 17, 2019 7:50 pm 
Offline
Moderator
Moderator
User avatar

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 1106
Location: Germany::Berlin()
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.

_________________
ImageImageImageImage Image


Top
 Profile  
Reply with quote  
 Post subject: Re: how to get the state of hardisk to make visual led state
PostPosted: Sat May 18, 2019 11:53 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Nov 03, 2005 12:30 pm
Posts: 117
Location: Italy
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
:) :) :)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 20 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye