473,805 Members | 2,297 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Avoid standby under vista with c# ?

Hi i'm searching a solution to avoid that the user can go in the standby
mode while a app is runing.

i have searched and readed a lot in the web and have not found a working
solution...
for the moment i use "away mode" under vista to get simiar results but with
other handycaps like screen off etc. :-(
i have get this code from a other dev but it doesnt work with vista, the pc
its going directly in the standby mode.

------------------------------------------
using System;
using System.Windows. Forms;
using System.Runtime. InteropServices ;

namespace MonitorSleepPre vent
{
public partial class Form1 : Form
{
public Form1()
{
InitializeCompo nent();
}

[DllImport("kern el32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern EXECUTION_STATE SetThreadExecut ionState(
EXECUTION_STATE flags);

[Flags]
public enum EXECUTION_STATE : uint
{
ES_SYSTEM_REQUI RED = 0x00000001,
ES_DISPLAY_REQU IRED = 0x00000002,
// ES_USER_PRESENT = 0x00000004,
ES_CONTINUOUS = 0x80000000
}

void PreventMonitorP owerdown()
{
SetThreadExecut ionState( EXECUTION_STATE .ES_DISPLAY_REQ UIRED |
EXECUTION_STATE .ES_CONTINUOUS) ;
}

void AllowMonitorPow erdown()
{
SetThreadExecut ionState(EXECUT ION_STATE.ES_CO NTINUOUS);
}

private void Form1_Load(obje ct sender, EventArgs e)
{
PreventMonitorP owerdown();
}
}
}
------------------------------------------

please help me to get a working solution for that

what i need is:

if the app is running and the user is pressing the power button (standby) or
uses the start\shutdown( standby) menu the pc should still on.

thank you for any tips
Volkan

Jun 27 '08 #1
7 3513
On Wed, 21 May 2008 07:01:36 -0700, Volkan Senguel <mo******@2wire .ch>
wrote:
[...]
if the app is running and the user is pressing the power button
(standby) or
uses the start\shutdown( standby) menu the pc should still on.
I'm not convinced you can do this. The OS provides ways for an
application to tell it not to go into standby/hibernate/screen-saver
automatically. But if the user explicitly commands that, I don't think
there's much you can do about that. Ultimately, the OS needs to respect
the user's wishes.

Pete
Jun 27 '08 #2
Sure i know that, but in Windows XP was possible to avoid the standby mode
by a application so that the user can not force the standby... only shutdown
etc...

Under Vista does this not work because Vista doesnt broadcast the suspend
message anymore, and by changing the SetThreadExecut ionState does not work
:-(

Infos from Microsoft:
http://download.microsoft.com/downlo...plications.ppt

Windows Vista will not query user mode components when entering sleep
PBT_APMQUERYSUS PEND event will not be sent

Windows Vista will continue to notify user mode components when entering
sleep
PBT_APMSUSPEND event is sent
Timeout has been reduced from 20s to 2s
Use this event to do limited cleanup before the suspend transition
Realy i dont know how to handle this because we have a multimedia app which
works flawless under xp, users can record and not go into standby while
reording is in progress.
Under Vista, user goes to standby and the recording are lost (!)

thats the reason why i need a working solution for that.

thank you
Volkan
"Peter Duniho" <Np*********@nn owslpianmk.coms chrieb im Newsbeitrag
news:op******** *******@petes-computer.local. ..
On Wed, 21 May 2008 07:01:36 -0700, Volkan Senguel <mo******@2wire .ch>
wrote:
>[...]
if the app is running and the user is pressing the power button
(standby) or
uses the start\shutdown( standby) menu the pc should still on.

I'm not convinced you can do this. The OS provides ways for an
application to tell it not to go into standby/hibernate/screen-saver
automatically. But if the user explicitly commands that, I don't think
there's much you can do about that. Ultimately, the OS needs to respect
the user's wishes.

Pete

Jun 27 '08 #3
Heh, dont eaven know what that is..
>PBT_APMSUSPE ND event is sent
Timeout has been reduced from 20s to 2s
Use this event to do limited cleanup before the suspend transition
Just a thought, why not send a keystroke from the program, "left/right
shift pressed" to avoid that (watch out for KVM:s timeout) ... a timer
and ... voila...

Or, too stupid approach? I use KISS, so Keep It Simple Stupid ;) so
dont use it.

//CY
Jun 27 '08 #4
On Wed, 21 May 2008 11:48:27 -0700, Volkan von Klass <mo******@2wire .ch>
wrote:
Sure i know that, but in Windows XP was possible to avoid the standby
mode by a application so that the user can not force the standby... only
shutdown etc...

[...]

Realy i dont know how to handle this because we have a multimedia app
which works flawless under xp, users can record and not go into standby
while reording is in progress.
Under Vista, user goes to standby and the recording are lost (!)
I really don't understand what you're saying.

If you mean that Vista itself is automatically trying to go into standby
mode, and you're unable to prevent that, then yes...I agree there should
be an API in the OS that allows that, and frankly the existing one that
works in XP ought to work in Vista too.

But if you mean that you can in XP prevent the system from going into
standby even when the user has explicitly told it to, and that you're
disappointed that that no longer works in Vista, well... My opinion is
that the XP behavior was a bug, and I'm happy to hear they fixed it in
Vista.

If the latter scenario is what you're talking about, the solution is to
tell your users to stop putting the system into standby mode when they are
trying to use the computer record.

If the former, I would report it as a bug against Vista
(http://connect.microsoft.com/), as well as contact Microsoft through
their support web site (http://support.microsoft.com/) and file a support
request against Vista. I have found that on occasion, filing a support
request results in a confirmation of the bug as well as help to work
around the problem.

Pete
Jun 27 '08 #5


"Peter Duniho" wrote:
On Wed, 21 May 2008 11:48:27 -0700, Volkan von Klass <mo******@2wire .ch>
wrote:
Sure i know that, but in Windows XP was possible to avoid the standby
mode by a application so that the user can not force the standby... only
shutdown etc...

[...]

Realy i dont know how to handle this because we have a multimedia app
which works flawless under xp, users can record and not go into standby
while reording is in progress.
Under Vista, user goes to standby and the recording are lost (!)

I really don't understand what you're saying.

If you mean that Vista itself is automatically trying to go into standby
mode, and you're unable to prevent that, then yes...I agree there should
be an API in the OS that allows that, and frankly the existing one that
works in XP ought to work in Vista too.

But if you mean that you can in XP prevent the system from going into
standby even when the user has explicitly told it to, and that you're
disappointed that that no longer works in Vista, well... My opinion is
that the XP behavior was a bug, and I'm happy to hear they fixed it in
Vista.

If the latter scenario is what you're talking about, the solution is to
tell your users to stop putting the system into standby mode when they are
trying to use the computer record.

If the former, I would report it as a bug against Vista
(http://connect.microsoft.com/), as well as contact Microsoft through
their support web site (http://support.microsoft.com/) and file a support
request against Vista. I have found that on occasion, filing a support
request results in a confirmation of the bug as well as help to work
around the problem.

Pete
I came across searching for a solution similar to the scenario that volkan
describes and hi is absotut right.

Think of an htpc with multiple tuners: the user schedules recordings and
used the system for watching live tv. If the user finished watching live tv
he/she uses the remote to power of the system, regardless of backround
recordings in process . Now its up to the software to keep the system alive
until the recording is finished.
Jun 27 '08 #6
On Thu, 22 May 2008 13:54:01 -0700, Joerg
<Jo***@discussi ons.microsoft.c omwrote:
[...]
Think of an htpc with multiple tuners: the user schedules recordings and
used the system for watching live tv. If the user finished watching live
tv
he/she uses the remote to power of the system, regardless of backround
recordings in process . Now its up to the software to keep the system
alive
until the recording is finished.
We'll just have to agree to disagree. IMHO, if you're making an HTPC with
a remote that is directly hooked to the stand-by functionality of Windows,
that's a design bug and it's better addressed by fixing the way the remote
deals with the system than by trying to work around a fundamentally
correct behavior in the OS.

Pete
Jun 27 '08 #7
I came across searching for a solution similar to the scenario that volkan
describes and hi is absotut right.

Think of an htpc with multiple tuners: the user schedules recordings and
used the system for watching live tv. If the user finished watching live
tv
he/she uses the remote to power of the system, regardless of backround
recordings in process . Now its up to the software to keep the system
alive
until the recording is finished.
Thank you joerg, thats exactly what i mean.

the user doesnt handle this with his remote control or simulating any
keystrokes etc....

the system must stay online.

in windows xp was a feature that the system cant suspend, in vista,
microsoft changed this behaviour because a lot of developers had not used
corectly this feature.

any way

has any one a solution for that?

thank you for the help
Volkan
Jun 27 '08 #8

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

Similar topics

1
5587
by: Mahesh Hardikar | last post by:
Hi , Oracle 8.1.7.0.0 on HP-UX 11.0 EMC2 Disk Array We are in a process of implementing DR Site using Standby Database feature of Oracle. We have tested it on 2 NT machines here & things are going fine. I have few questions about Standby Database which I could not find answer in Backup Recovery Guide.
0
3927
by: Cherrish Vaidiyan | last post by:
hello, Thanx for the suggestions on my Listener query. Now i am performing a simple work.. STANDBY DATABASE creation. I have followed the instraction from Oracle 9i Release 1 documentation but have some doubts. here are the basic stpes i followed. 1 Either make a new backup of the primary database datafiles or access
0
3343
by: Cherrish Vaidiyan | last post by:
sir, The following are the steps that i followed in setting up standby database on Red hat Linux 9. i am using Oracle 9i. i have followed the steps in this site : http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96653/create_ps.htm#66206 Still i give the steps i followed. Preparing the Primary Database for Standby Database Creation
6
21990
by: shorti | last post by:
db2 8.1 fix pack 12 on AIX 5.3 This is a newly configured HADR machine. The HADR was up and running. I was 'playing' around some on the standby and did a db2 deactivate and things sort of went down hill from there. Though the Standby machine seemed to know it was a standby it would not connect to the primary. I could not even do a db2 get snapshot to view the hadr status on the machine. I was wanting to do a few HADR tests before I...
56
3646
by: Squishy | last post by:
I tried installing my VS2005 Pro on Vista Ultimate 32 bit RTM today and got errors stating that VS2005 was not compatible with Vista. Microsoft......please pull your finger out of my ass and tell me this is a joke. It must be a joke....because I also have read that VS2002 and VS2003 will not be supported on Vista. This clearly violates Microsoft's own terms of support for these products.
2
5202
by: paul | last post by:
Hi, I have two databases in hadr, this morning i issued a "takeover ... by force" because the normal takeover didn't worked. Now i have two standard databases, and if i try to put the old primary database in standby mode i can't but it's not in rollforward pending state. How can i put this database in rollffoward pending state without backup/restore from the new primary dabatase ?
0
4731
by: Vinod Sadanandan | last post by:
STANDBY DATABASE MONITORING & PROTECION MODES (9iR2) This document is written for understanding and monitoring standby database configured with diffrent protection modes . MAXIMUM PROTECTION -Guarantees that no data loss will occur if the primary database fails. To provide this level of protection, the redo data needed to recover each transaction must be written to both the local online redo log and to a standby redo log on at least...
4
4205
by: Mark A | last post by:
I would like to make a split mirror copy of a HADR standby database. Please note that I do not want to create a standby with a split mirror of the primary, but I want to make a split mirror of the standby (for a reporting database). I know that I cannot do a write suspend on the standby because it does not allow any connections. But what if I just did a split mirror of the standby, do a db2inidb, then ship the logs over to the split...
0
1791
by: Peter Van Peborgh | last post by:
I have an app that is built in Access 2002 and packaged with its runtime. When installing it in a Vista PC/laptop, several dialog boxes pop up that require specific answers for the app to install and work OK under Vista. Is there any way to make this installation more straightforward by pre-empting these dialog boxes and/or answering them automatically so that the User does not have to do it himself and probably get it wrong? Here is what I...
0
9596
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10370
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
10109
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
9186
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...
1
7649
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5545
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
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4328
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.