473,802 Members | 2,267 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Detecting the ScreenSaver State

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

BOOL b=SystemParamet ersInfo(SPI_GET SCREENSAVERRUNN ING, 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 15236
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("user 32.dll", CharSet=CharSet .Auto)]
public static extern int SystemParameter sInfo(int uAction,
int uParam, ref int lpvParam, int fuWinIni);

const int SPI_GETSCREENSA VERRUNNING = 114;
int screenSaverRunn ing = -1;

// is the screen saver running?

int ok = SystemParameter sInfo(SPI_GETSC REENSAVERRUNNIN G, 0, ref
screenSaverRunn ing, 0);

if (ok == 0)
{
Console.WriteLi ne("Call to SystemParameter sInfo failed.");
}

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

}

ok,
aq

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

BOOL b=SystemParamet ersInfo(SPI_GET SCREENSAVERRUNN ING, 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("user 32.dll", CharSet=CharSet .Auto)]
public static extern int SystemParameter sInfo(int uAction,
int uParam, ref int lpvParam, int fuWinIni);

const int SPI_GETSCREENSA VERRUNNING = 114;
int screenSaverRunn ing = -1;

// is the screen saver running?

int ok = SystemParameter sInfo(SPI_GETSC REENSAVERRUNNIN G, 0, ref
screenSaverRunn ing, 0);

if (ok == 0)
{
Console.WriteLi ne("Call to SystemParameter sInfo failed.");
}

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

}

ok,
aq

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

BOOL b=SystemParamet ersInfo(SPI_GET SCREENSAVERRUNN ING, 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
1624
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
4183
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. However I am unable to detect the screensaver starting when the screensaver password option is disabled. When using the WndProc Overrides I am unable to capture the screensaver event unless the application is active . Thank you in advance for any...
7
1882
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 generated menu on my site; with CSS enabled it looks great, but when CSS is disabled it prints out all these menu options inline and you have to scroll past them (a pain in the ass). Is there any way to tell if the user has CSS enabled or disabled...
3
9271
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 polling at each timer click.. private void tick(object sender, System.EventArgs e) { const int SPI_GETSCREENSAVERRUNNING = 114; int screenSaverRunning = -1; // is the screen saver running?
0
1070
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 directive or web.config file. it is enabled in both has anyone else had similar problems? Adrian
7
1430
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 is sufficient. Can anyone confirm or deny? TIA...
4
2615
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
2980
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. I am new in C# and I am checking for some hints on how to do it. Thanks! VMAM
8
5964
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 check, but I cannot find any articles about it anywhere, nor could I find it in the Microsoft language reference. I know that is it possible, as, for example, Windows will not a "remote" user run a Direct3D app. It pops up a message saying something...
0
9699
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10536
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10285
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10063
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9114
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6838
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5494
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3792
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.