I was converting some MSDN code to masm (using SetWindowsHookEx for a system wide hook), but it wasn't working. So then I figured that I should do a small proof of concept without hooks just for grins. But this isn't working either. All that I'm trying to do is stop the screensaver from starting. From MSDN, it looks like you just check WM_SYSCOMMAND for a wParam value of SC_SCREENSAVE and then return zero. It's not stopping the screensaver though. I did some quick messagebox debugging and I'm getting through the 'cmp wParam,lSC_SCREENSAVE' code, but the screensaver still fires. Does anyone have some info on preventing the screensaver from starting?

Posted on 2004-12-17 12:26:27 by Will
I have never actually tried this before (no need to). Are you masking the uCmdType parameter? Perhaps this is causing a failure?

In WM_SYSCOMMAND messages, the four low-order bits of the uCmdType parameter are used internally by Windows. To obtain the correct result when testing the value of uCmdType, an application must combine the value 0xFFF0 with the uCmdType value by using the bitwise AND operator.

Dont know if this is the issue or not...
Posted on 2004-12-17 14:12:49 by Graebel
Well I'm not quite sure what the use of that param would be, but since it mentions that it's used internally by windows and it doesn't seem to be mentioned anywhere else I had initially ignored it. I just tried it though, and there's no change.

the link to one of about 3 msdn pages that I've found about this topic.

It's also in Nehe's 1st (1st windows tut, the 1st one is actually for the mac) opengl tut. My code is slightly different (syntactically) from the masm source posted with that article. That code works on my win2k box, but not my winxp box.

I'm starting to think that maybe there is some sort of restriction in place on this machine. Any other ideas?


I'm trying to implement this on a winxp box if that matters.
Posted on 2004-12-17 15:43:09 by Will
Afternoon, Will.

I also have Windows XP and just returning 0 from the SC_SCREENSAVE message handler didn't work.

Here's a workaround whereby a keyboard message is sent during the SC_SCREENSAVE message handling which makes the screensaver think someone's pressed and released a shift key.


It will only work if the program is currently active though, which means it's pretty useless except for keeping fullscreen games paused for long periods of time.

Posted on 2004-12-18 03:36:25 by Scronty
Can't the SystemParametersInfo API be used for this? :idea:
Posted on 2004-12-19 14:54:37 by QvasiModo
Yes it can

ScreenSaver dd ?

;read screensaver status:
invoke SystemParametersInfo,SPI_GETSCREENSAVEACTIVE,0,addr ScreenSaver,0

;in/activate screensaver:

Posted on 2004-12-20 08:41:30 by Siekmanski
I thought that SystemParametersInof was only compatible with win9x.
Posted on 2004-12-20 12:21:28 by Will
Included in Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, Windows 98, and Windows 95.

I did test it on Windows 98 and Windows XP and it worked O.K.
Posted on 2004-12-20 12:57:16 by Siekmanski