473,396 Members | 2,024 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,396 software developers and data experts.

Detecting the ScreenSaver State

In C++ you can detect the screensaver state by using something like:

BOOL b=SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, NULL, &bOn, FALSE);

Is there an equivalent method that I can use in C#? If not, how can I
determine the state of the screen saver?

--
-Anthony
Nov 16 '05 #1
2 15168
This is from one of the forums, so you can test it yourself, but the idea is
to use interop to get the state from the SPI enum:

[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int SystemParametersInfo(int uAction,
int uParam, ref int lpvParam, int fuWinIni);

const int SPI_GETSCREENSAVERRUNNING = 114;
int screenSaverRunning = -1;

// is the screen saver running?

int ok = SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, ref
screenSaverRunning, 0);

if (ok == 0)
{
Console.WriteLine("Call to SystemParametersInfo failed.");
}

if (screenSaverRunning != 0)
{
// screen saver is running

}

ok,
aq

"Anthony" <An*****@discussions.microsoft.com> wrote in message
news:F3**********************************@microsof t.com...
In C++ you can detect the screensaver state by using something like:

BOOL b=SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, NULL, &bOn, FALSE);

Is there an equivalent method that I can use in C#? If not, how can I
determine the state of the screen saver?

--
-Anthony

Nov 16 '05 #2
Thanks!!! This is what I need

"Ahmed Qurashi" wrote:
This is from one of the forums, so you can test it yourself, but the idea is
to use interop to get the state from the SPI enum:

[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int SystemParametersInfo(int uAction,
int uParam, ref int lpvParam, int fuWinIni);

const int SPI_GETSCREENSAVERRUNNING = 114;
int screenSaverRunning = -1;

// is the screen saver running?

int ok = SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, ref
screenSaverRunning, 0);

if (ok == 0)
{
Console.WriteLine("Call to SystemParametersInfo failed.");
}

if (screenSaverRunning != 0)
{
// screen saver is running

}

ok,
aq

"Anthony" <An*****@discussions.microsoft.com> wrote in message
news:F3**********************************@microsof t.com...
In C++ you can detect the screensaver state by using something like:

BOOL b=SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, NULL, &bOn, FALSE);

Is there an equivalent method that I can use in C#? If not, how can I
determine the state of the screen saver?

--
-Anthony


Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Greg Miskin | last post by:
How do I detect whether the workstation is locked? Also, how can I determine if a screensaver is running? Thanks, Greg
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. ...
7
by: Michael Crute | last post by:
I did a search and basically came up with nothing for this question, but if I missed the answer, I apologize in advance, please just point me in the right direction. OK, I am using a JavaScript...
3
by: sanjana | last post by:
hi i want to fire an event if the screen saver starts up i have done it using a timer tick event where i have used the api function to detect if screensaver has started..but this means continuous...
0
by: Adrian Bezzina | last post by:
I am setting a session variable, then doing a server.transfer in global.aspx and the page I am going to is saying that session state is not enable and that I should enable it in either the page...
7
by: glen | last post by:
I'm looking for a way to detect if another process has a file open before a second process tries to open it. I've looked into the FileAttr function but I'm not sure if detecting a read-only state...
4
by: steve | last post by:
Hi All Using VB net 2005 Professional how can I detect when the windows screen saver starts running Regards Steve
3
by: =?Utf-8?B?Vk1BTQ==?= | last post by:
Hi, I have a home network with a DSL router. I want to check the router state (connected, disconnected...) from an XP computer on the network by showing an icon (green / red) in the system tray....
8
SqUiMbO
by: SqUiMbO | last post by:
I have been searching and searching for a way to detect whether or not the user who launched my application is a local user or someone that is "remoted" in. This sounds like a very simple thing to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.