Stop screensaver

Hello all,

i need a way to stop screensaver under XP/2000/2003/Vista.

MSDN show the famous code below for this:

BOOL CALLBACK KillScreenSaverFunc(HWND hwnd, LPARAM lParam)
{
if( IsWindowVisible( hwnd ) )
{
PostMessage ( hwnd, WM_CLOSE, 0, 0 );
return true;
}
return false;
}

void stop_screen_saver()
{
HDESK hdesk;

hdesk = OpenDesktopA((char*)"Screen-saver", 0, FALSE, DESKTOP_READOBJECTS | DESKTOP_WRITEOBJECTS);

if (hdesk)
{
EnumDesktopWindows (hdesk, KillScreenSaverFunc, 0);
CloseDesktop (hdesk);
}
else
{
PostMessage(GetForegroundWindow(), WM_CLOSE, 0, 0L);
}
}



This code generally work, but not if i am running a screensaver that use hw acceleration as GL or ActiveX. In particular, i am testing with FanFish25 saver, a kind of aquarium.
After WM_CLOSE, seems that it'is killed, but mouse click don't work anymore and screensaver continue to run. Only pressing ctrl+alt+canc works now, and this drive me directly to the login screen.

Every help is really appreciated.
Angelo




Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories