Thread View: borland.public.cppbuilder.nativeapi
7 messages
7 total messages
Started by Mike Collins
Fri, 19 May 2006 15:46
SetSystemPowerState issues
Author: Mike Collins
Date: Fri, 19 May 2006 15:46
Date: Fri, 19 May 2006 15:46
39 lines
2904 bytes
2904 bytes
Hi guys - it must be bug Friday for me today, two posts in a row. Having another issue, this time relating to SetSystemPowerState(). In our application be have a system, similar to the Microsoft shutdown dialog where the user can choose how they want to close the Windows session i.e. restart, shutdown, hibernate or stand-by. All options seem to work except the hibernate / stand-by. The only way i could find to implement either of these was with SetSystemPowerState(). However I have discovered that on some systems you do not seem to be able to place the OS in either of these states i.e. if you use the normal MS shutdown dialog it does not have either of these options available. And in following with this, if our application tried to implement a stand-by or hibernate on these systems, it causes considerable problems resulting in BSOD and system restart. What usually happens is that the system will a) display the MS shutdown message but not proceed any further, or b) appear to hibernate but not turn off the PSU / CPU fans. When (b) happens, if I try to re-activate the system using the power button, it appear to re-start and then I get a page-fault BSOD. What I need to know is, is there any way to detect or determine if the system can or can't be placed in either of theses modes? I've notices on the Windows XP Home edition shutdown that under certain circumstances and configurations, the Stand-By or Hibernate buttons may be disabled. This is exactly what I need to determine... My second question, (in following with this) is, does my application (or any other running on the system) need to perform any specialist operations before the system is suspended. For example, we have a hardware polling thread - does this need to be specifically suspended by our application or does the OS take care of these aspects? As usual, any help or pointers would be gratefully received, Many thanks in advance, Mike C
Re: SetSystemPowerState issues
Author: Bob Gonder
Date: Fri, 19 May 2006 18:39
Date: Fri, 19 May 2006 18:39
25 lines
2214 bytes
2214 bytes
Mike Collins wrote: >All options seem to work except the hibernate / stand-by. The only way i >could find to implement either of these was with SetSystemPowerState(). > >What I need to know is, is there any way to detect or determine if the >system can or can't be placed in either of theses modes? I think you want to look at GetPwrCapabilities() http://msdn.microsoft.com/library/default.asp?url=/library/en-us/power/base/getpwrcapabilities.asp I should think that HiberFilePresent would indicate if hibernation is available. Don't know what the various SystemS1 sleep states are. >My second question, (in following with this) is, does my application (or any >other running on the system) need to perform any specialist operations >before the system is suspended. For example, we have a hardware polling >thread - does this need to be specifically suspended by our application or >does the OS take care of these aspects? Well, that depends on if your hardware/polling can withstand a long interruption. If your application or the hardware crashes with sleep or hibernate, then, yes, they should check for those system messages and take care of themselves. If they don't care about the missed polls, then nothing is needed. The app will just go to sleep.
Re: SetSystemPowerState issues
Author: Mike Collins
Date: Sat, 20 May 2006 12:06
Date: Sat, 20 May 2006 12:06
11 lines
1442 bytes
1442 bytes
Thanks bob, got me looking in the right place in MSDN now. Whilst there I also noticed, IsPwrSuspendAllowed() and IsPwrHibernateAllowed(). I'm just testing them now but the names allow sound promising... Thanks alot "Bob Gonder" <notbg@notmindspring.invalid> wrote in message news:hi3s625hiq004edghi6b2c57otqvstpehp@4ax.com... > Mike Collins wrote: >
Re: SetSystemPowerState issues
Author: Mike Collins
Date: Sat, 20 May 2006 12:47
Date: Sat, 20 May 2006 12:47
11 lines
1323 bytes
1323 bytes
By the way, is there aomething specific you need to do to use the functions in powrprof.h? Do you have to dynamically load the DLL and use GetProcAddress? Thanks again, mike... "Bob Gonder" <notbg@notmindspring.invalid> wrote in message news:hi3s625hiq004edghi6b2c57otqvstpehp@4ax.com... > Mike Collins wrote: >
Re: SetSystemPowerState issues
Author: Bob Gonder
Date: Sat, 20 May 2006 14:50
Date: Sat, 20 May 2006 14:50
15 lines
1547 bytes
1547 bytes
Mike Collins wrote: >By the way, is there aomething specific you need to do to use the functions >in powrprof.h? You would want to link with the lib file. But it sounds like if you did, then your application wouldn't run on a 95 system. With LoadLibrary, you could detect that, and disable the specials. To get a lib file to link with, locate the dll, and use implib on it. >Do you have to dynamically load the DLL and use GetProcAddress? Might be best, if you need to also support Win95.
Re: SetSystemPowerState issues
Author: Boba
Date: Tue, 23 May 2006 22:27
Date: Tue, 23 May 2006 22:27
12 lines
1233 bytes
1233 bytes
"Bob Gonder" <notbg@notmindspring.invalid> wrote in message news:hi3s625hiq004edghi6b2c57otqvstpehp@4ax.com... > ... > Don't know what the various SystemS1 sleep states are. > ... s0 - everything is up & running s1 - cpu halt, mem refreshing s2 - cpu halt, mem refr. slow s3 - cpu off, mem refr. slow (power supply low) s4 - cpu off, mem swapped s5 - everything is off, need reboot
Re: SetSystemPowerState issues
Author: Boba
Date: Wed, 24 May 2006 15:36
Date: Wed, 24 May 2006 15:36
6 lines
1068 bytes
1068 bytes
no sure: > s2 - cpu halt, mem refr. slow should be: s2 - cpu off, ram refr. normal correct me please.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads