473,386 Members | 1,796 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Setting up screensaver via CSharp/C# application

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
Nov 16 '05 #1
3 5627
Not exactly sure if this will help, but here's a URL that might help?

http://www.codeproject.com/csharp/scrframework.asp

HTH a bit. Good luck.
Nov 16 '05 #2
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: klappnase | last post by:
Hello everyone, does anyone know a way to stop the screensaver under linux from starting up while a certain process is running? I need this because I experience a memory leak while recording...
4
by: Christopher Burr | last post by:
I'm trying to set the user's screensaver in the .NET world... In Win32 I could use a combination of setting the screen saver name via the registry and then setting the time and active status...
0
by: Luke | last post by:
I am trying to capture an event when the screensaver starts. I have code working on Windows XP etc when the Password/Welcome Screen is enabled . Using the Fast User Switching Notifications. ...
2
by: DanielB | last post by:
Does anyone know what the command line argumentto launch a screensaver's options/configuration dialog is on Windows XP Pro? From most of the example source code I can find on the web, it would...
0
by: Rick | last post by:
I am trying to stop the screen saver from running based on a external trigger from our application. I have a .Net application and I am using interop to make a SystemParameterInfo() call to...
1
by: Angel | last post by:
Hello everyone, How can I build a simple screensaver that only displays images? Are there any pages that display some examples? I posted this question a few months ago but the examples were way...
4
by: Simon Mercer | last post by:
I have been trying to build a screensaver that will connect to a database and display specific data depending on the user that is logged in. I have managed to get a simple data access screensaver...
0
by: jim.long | last post by:
I am in the learning fazes of writing a c# screensaver that will take into account a second monitor. the basic code I have has a problem and i am not sure what it might be. What it is doiing is...
6
by: mateusz.zajakala | last post by:
Hello, I have strange problem. I let my application work (it tests in loop with 3sec brakes if it's possible to connect to remote pc /by ssh/) and do nothing until screensaver activates. After...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.