Public struct PowerRequestContextDetailedInformation parameter of type POWER_REQUEST_CONTEXT_DETAILED. define the PowerCreateRequest function with the first POWER_REQUEST_CONTEXT only supports SimpleReasonString. To avoid runtime interop issues, this version of internal union of SimpleReasonString and Detailed information. Note: Windows defines the POWER_REQUEST_CONTEXT structure with an Availablity Request Enumerations and ConstantsĬonst int POWER_REQUEST_CONTEXT_VERSION = 0 Ĭonst int POWER_REQUEST_CONTEXT_SIMPLE_STRING = 0x1 Ĭonst int POWER_REQUEST_CONTEXT_DETAILED_STRING = 0x2 Internal static extern int CloseHandle(IntPtr hObject) Static extern bool PowerClearRequest(IntPtr PowerRequestHandle, PowerRequestType RequestType) Static extern bool PowerSetRequest(IntPtr PowerRequestHandle, PowerRequestType RequestType) Static extern IntPtr PowerCreateRequest(ref POWER_REQUEST_CONTEXT Context) POWER_REQUEST_CONTEXT _PowerRequestContext
#region prevent screensaver, display dimming and automatically sleeping With the linked AvailabilityRequests.docx on msdn which is exhausting to get into it (too much to read), I have searched the web for a concrete example in c# that is based on the PowerCreateRequest and found Ĭopied and adapted it to my needs (PInvoke of CloseHandle copied from msdn): using 'Using PowerCreateRequest, PowerSetRequest, and PowerClearRequest