PowerSetRequest function
Applies to: desktop apps only
Increments the count of power requests of the specified type for a power request object.
Syntax
BOOL PowerSetRequest( __in HANDLE PowerRequest, __in POWER_REQUEST_TYPE RequestType );
Parameters
- PowerRequest [in]
-
A handle to a power request object.
- RequestType [in]
-
The power request type to be incremented. This parameter can be one of the following values.
Return value
If the function succeeds, it returns a nonzero value.
If the function fails, it returns zero. To get extended error information, call GetLastError.
Remarks
To conserve power and provide the best user experience, applications that use power requests should follow these best practices:
- When creating a power request, provide a localized text string that describes the reason for the request in the REASON_CONTEXT structure.
- Call PowerSetRequest immediately before the scenario that requires the request.
- Call PowerClearRequest to decrement the reference count for the request as soon as the scenario is finished.
- Clean up all request objects and associated handles before the process exits or the service stops.
Requirements
|
Minimum supported client | Windows 7 |
|---|---|
|
Minimum supported server | Windows Server 2008 R2 |
|
Header |
|
|
Library |
|
|
DLL |
|
See also
Send comments about this topic to Microsoft
Build date: 2/7/2012
Documentation Clarification
Hey, I'm working with this API as well and saw your complaints, and wanted to help answer your questions.
1) PowerRequestExecutionRequired is new to windows 8, as the documentation states that this is available starting in Windows Developer Preview. Consequently, only Visual Studio 2011 Developer Preview running on Windows Developer Preview would pick this up.
2) Regarding how PowerCreateRequest works, I find the documentation for that function (linked from this page) and the description of REASON_CONTEXT (linked from the PowerCreateRequest page) to be adequate enough for my application - are there more specific questions that aren't addressed?
- 12/15/2011
- Sean Kelly [MSFT]
Documentation Clarification
Hey, I'm working with this API as well and saw your complaints, and wanted to help answer your questions.
1) PowerRequestExecutionRequired is new to windows 8, as the documentation states that this is available starting in Windows Developer Preview. Consequently, only Visual Studio 2011 Developer Preview running on Windows Developer Preview would pick this up.
2) Regarding how PowerCreateRequest works, I find the documentation for that function (linked from this page) and the description of REASON_CONTEXT (linked from the PowerCreateRequest page) to be adequate enough for my application - are there more specific questions that aren't addressed?
- 12/15/2011
- Sean Kelly [MSFT]
This documentation isn't very helpful
As someone who is trying to perform programmatic system and/or monitor power state manipulation on Windows Vista and 7, I find the documentation on the whole topic to be very muddled, contradictory and incomplete.
Why isn't PowerRequestExecutionRequired defined in any header files?
How does PowerCreateRequest work and what should be passed in the REASON_CONTEXT structure?
What is the definitive way to put a monitor into powersave mode?
etc, etc, etc.
- 12/8/2011
- Fistynuts1
Inconsistencies yet again
This page is the only one that mentions "PowerRequestExecutionRequired"
What happened to it ?
POWER_REQUEST_TYPE enumeration
http://msdn.microsoft.com/en-us/library/windows/desktop/dd405534(v=vs.85).aspx
Doesn't mention it at all.
Visual studio 2010 sp1 doesn't define it.
Was it removed in the last minute ?
- 11/9/2011
- JamesWebb