R
Ron Nanko
Hi,
I'm trying to setup a screensaver via a C# application. What I
currently do is this:
[DllImport("user32", CharSet=CharSet.Auto)]
unsafe public static extern short SystemParametersInfo (int uiAction,
int uiParam, int* pvParam, int fWinIni);
....
try
{
RegistryKey oKey = Registry.CurrentUser.OpenSubKey("Control Panel",
true);
oKey = oKey.OpenSubKey("desktop", true);
oKey.SetValue("SCRNSAVE.EXE", in_sSaver);
oKey.SetValue("ScreenSaveActive", "1");
unsafe
{
int nX = 1;
SystemParametersInfo(
SPI_SETSCREENSAVEACTIVE,
0,
&nX,
0
);
}
}
catch (Exception exc)
{
System.Windows.Forms.MessageBox.Show(exc.ToString());
}
However, when I execute this code and change to the MS Windows Display
Propert ies (Screensaver tab), the current screensaver is always set
to "none".
In the registry under HKCU/Control Panel/Desktop both SCRNSAVE.EXE and
ScreenSaveActive are set properly.
What is wrong?
Thanks in advance,
Ron
I'm trying to setup a screensaver via a C# application. What I
currently do is this:
[DllImport("user32", CharSet=CharSet.Auto)]
unsafe public static extern short SystemParametersInfo (int uiAction,
int uiParam, int* pvParam, int fWinIni);
....
try
{
RegistryKey oKey = Registry.CurrentUser.OpenSubKey("Control Panel",
true);
oKey = oKey.OpenSubKey("desktop", true);
oKey.SetValue("SCRNSAVE.EXE", in_sSaver);
oKey.SetValue("ScreenSaveActive", "1");
unsafe
{
int nX = 1;
SystemParametersInfo(
SPI_SETSCREENSAVEACTIVE,
0,
&nX,
0
);
}
}
catch (Exception exc)
{
System.Windows.Forms.MessageBox.Show(exc.ToString());
}
However, when I execute this code and change to the MS Windows Display
Propert ies (Screensaver tab), the current screensaver is always set
to "none".
In the registry under HKCU/Control Panel/Desktop both SCRNSAVE.EXE and
ScreenSaveActive are set properly.
What is wrong?
Thanks in advance,
Ron