It is currently Sun May 19, 2019 9:33 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: How to detect Windows hibernation mode?
PostPosted: Sat May 11, 2019 1:39 pm 
Offline
Enthusiast
Enthusiast

Joined: Sat Feb 08, 2014 3:26 pm
Posts: 597
Location: France
WM_QUERYENDSESSION detects the end of the session, but is it possible to detect the Windows hibernation ?

The reason: I would like to be able to stop the web radio and/or MP3 play of my programs (ACME Desk and ACME MediaPlayer) when the user clicks on Hibernation mode (Hibernation mode launch by Windows or by command: rundll32.exe powrprof.dll,SetSuspendState 1,0,1) Otherwise, the music will immediately resume from deep sleep.

:wink:

_________________
(English is not my native language, I use an online translator)


Last edited by Marc56us on Sat May 11, 2019 1:48 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: How to detect Windows hibernation mode?
PostPosted: Sat May 11, 2019 1:48 pm 
Offline
Moderator
Moderator
User avatar

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 831
Location: Berlin and Ibiza
Code:
EnableExplicit

Procedure WinCallback(hWnd, uMsg, wParam, lParam)
 
  Select uMsg
    Case #WM_POWERBROADCAST
      Select wParam
        Case #PBT_APMSUSPEND
          Debug "PC now goes into hibernation."
         
      EndSelect
  EndSelect
 
  ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure

If OpenWindow(0, 0, 0, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
 
  SetWindowCallback(@WinCallback())
 
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        End
    EndSelect
  ForEver
EndIf

_________________
ImageImageImageImageImage


Top
 Profile  
Reply with quote  
 Post subject: Re: How to detect Windows hibernation mode?
PostPosted: Sat May 11, 2019 2:05 pm 
Offline
Enthusiast
Enthusiast

Joined: Sat Feb 08, 2014 3:26 pm
Posts: 597
Location: France
Thank you RSBasic, it works perfectly now 8)

:idea: A subsidiary question: Is there a way to interrupt (or pause some seconds) the start of this sleep mode while something is displayed?
:?: Maybe cancel the standby request completely, continue the program, then launch the software standby?
But I don't think Windows allows software to interrupt a stop command (as you can do under unix with shutdown)

(Put in extended sleep mode by command, I know how to do it with runprogram and rundll32.exe powrprof.dll,SetSuspendState 1,0,1)

_________________
(English is not my native language, I use an online translator)


Top
 Profile  
Reply with quote  
 Post subject: Re: How to detect Windows hibernation mode?
PostPosted: Sat May 11, 2019 2:23 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Apr 10, 2017 6:17 pm
Posts: 189
Location: Germany
In the past you could return #PWR_FAIL to abort the suspend, do stuff and later init suspend again. But it might not work with #WM_POWERBROADCAST anymore.


Top
 Profile  
Reply with quote  
 Post subject: Re: How to detect Windows hibernation mode?
PostPosted: Sat May 11, 2019 3:11 pm 
Offline
Enthusiast
Enthusiast

Joined: Sat Feb 08, 2014 3:26 pm
Posts: 597
Location: France
Here, both programs are updated to stop the radio and/or MP3 playback if the user puts in hibernation mode.
On my computer (Windows 10 x64) it works :)

Thanks to PureBasic for making programming so easy and therefore so productive 8)

With small scripts (cmd), I compile (PB project mode), archive (7zip), package (InnoSetup 6) and update (WinSCP) my site in a few clicks. (less than 2 min)

Thanks to the whole PB community for all the advice given here over the years.

:wink:

http://mdacme.com
Note: Web Page fore ACME Media Player is in french (for the moment) but software is in french and english.

_________________
(English is not my native language, I use an online translator)


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


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