By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,563 Members | 1,307 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,563 IT Pros & Developers. It's quick & easy.

Setting up screensaver via CSharp/C# application

P: n/a

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);
RegistryKey oKey = Registry.CurrentUser.OpenSubKey("Control Panel",
oKey = oKey.OpenSubKey("desktop", true);
oKey.SetValue("SCRNSAVE.EXE", in_sSaver);
oKey.SetValue("ScreenSaveActive", "1");

int nX = 1;
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,
Nov 16 '05 #1
Share this Question
Share on Google+
3 Replies

P: n/a
Not exactly sure if this will help, but here's a URL that might help?

HTH a bit. Good luck.
Nov 16 '05 #2

P: n/a
Thanks, but that's not what I was looking for - the article seems to
describe how to write a screensaver, while I need to set an existing
screensaver up via a C# application!

Nov 16 '05 #3

P: n/a
Just in order to answer my own question: the solution was rather
simple. My custom screensaver's filename had more than 8 characters,
obviously Windows messes things up then. I shortened it to 8 characters
and everything worked fine.

Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.