Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 16017

[RESOLVED] VB6 QUESTION: Detecting when PC comes back from sleep mode

$
0
0
Looking to detect when the PC comes back from sleep mode.

My dock sometimes freezes high during an animation when the system is put into sleep mode. It sometimes stays there when the PC restarts as the animation responds to the mouse when it is within the dock portion of the screen, after a restart the cursor is no longer within those bounds so the dock stays up.



I have a couple of solutions but it got me thinking about how VB6 can determine whether a PC has just awoken from sleep.

I was thinking of having a timer running every 20 seconds or so that stores the date and time of the last run. It then compares that stored value with the current date and time. If it finds a significant discrepancy between the two of more than a few minutes then it would assume that the PC has been in sleep or hibernate mode for that intervening period. This seems like a fairly simple but effective way of checking whether the PC that your program is running upon has been placed into sleep or hibernation.

Can you see any flaws with this approach? Any suggestions? I know there are ways of using power management and interpreting the WM messages but that seems overkill for my simple requirement.

Viewing all articles
Browse latest Browse all 16017

Latest Images

Trending Articles

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>