Disabling /Enabling screensaver

  • Thread starter Thread starter Genival Carvalho
  • Start date Start date
G

Genival Carvalho

Here is a simple code you can try.

Add this line to your code:
using System.Runtime.InteropServices;

Past the following two lines into your class.
[DllImport("user32", CharSet=CharSet.Auto)]
unsafe public static extern short SystemParametersInfo (int uiAction, int
uiParam, int* pvParam, int fWinIni);

And call the function like this:
int x = 1; // 0 for deactivating
SystemParametersInfo (17, 0, &x, 0); //SPI_SETSCREENSAVEACTIVE = 17

You can find more information about this API function in the Windows
Platform SDK documentation.

Hope this helps.
Genival - SP BR
 
Back
Top