473,325 Members | 2,342 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,325 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 15158
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
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.