Another SystemParametersInfo question

  • Thread starter Thread starter Dwight Trumbower
  • Start date Start date
D

Dwight Trumbower

I need to disable the screen saver, due to an Excel "bug".

I thought I had the following code working, but now all I get is code 127.
I've searched the net and I don't see anything wrong with the following.


[DllImport("user32.dll", CharSet=CharSet.Auto, SetLastError=true)]
public static extern int SystemParametersInfo(int uiAction, int uiParam,
string pvParam, int fuWinIni);

static void Main()
{
const int SPI_SETSCREENSAVEACTIVE = 17;
int screenStatus;
int retCode = 0 ;
screenStatus = 0; // disable screen saver
retCode = SystemParametersInfo (SPI_SETSCREENSAVEACTIVE, 0, "0",0);
if (retCode == 0 )
retCode = Marshal.GetLastWin32Error ();
MessageBox.Show ("Screen saver not turned off","Screen Saver"); //Deactivate
screen saver
}

Thanks
Dwight
 
Back
Top