Block screensaver/standby/energy management
-
Monday, April 07, 2008 2:46 PMHello,
A computer with default vista settings goes into standby / sleepmode after about 20 mins, but when I have a bittorrent client, backgroundownloader, liveupdater application or defrag running, this doesn't happen. So I need to find some way to let my pc know that my application is busy so it won't go into standby / sleep mode.
any idea?
Regards,
Aussie
All Replies
-
Monday, April 07, 2008 7:39 PM
Hi
The screen saver can be controlled by a native import of the user32.dll file (http://www.webtropy.com/articles/api/user32.dll.asp), you would basically need to write an application that monitors the processes that concern you, or you can check the CPU/memory/disk load, you can also monitor network traffic by checking the bytes read/write on the network interface during a certain period of time.
This is just a generic description of one possible way to do it, the implementation shouldn't be too difficult, most of the individual parts can be gathered around MSDN, but be sure to ask if you get stuck on a specific portion.
The easiest option is obviously just to disable these functions while you are performing these actions.
Best of luck.
Regards
Lionel Pinkhard
-
Wednesday, April 09, 2008 4:04 AM
You can prevent the screen saver from showing itself by overriding the Form.WndProc method, and suppress the WM_SYSCOMMAND message that has the SC_SCREENSAVE wparam, as shown in the following code:
Code Snippetprivate const int WM_SYSCOMMAND = 0x112;
private const int SC_SCREENSAVE = 0xF140;
private const int SC_MONITORPOWER = 0xF170;protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WM_SYSCOMMAND:
switch ((int)m.WParam)
{
case SC_MONITORPOWER:
return;
case SC_SCREENSAVE:
return;
}
break;
}
base.WndProc(ref m);
}
The code is quoted from:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2998554&SiteID=1

