{"id":4671,"date":"2014-03-30T14:29:58","date_gmt":"2014-03-30T14:29:58","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/what-line-of-code-could-i-use-in-c-to-disable-energy-saver-collection-of-common-programming-errors\/"},"modified":"2014-03-30T14:29:58","modified_gmt":"2014-03-30T14:29:58","slug":"what-line-of-code-could-i-use-in-c-to-disable-energy-saver-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/what-line-of-code-could-i-use-in-c-to-disable-energy-saver-collection-of-common-programming-errors\/","title":{"rendered":"What line of code could I use in C++ to disable energy saver?-Collection of common programming errors"},"content":{"rendered":"<pre><code>class KeepDisplayOn\n{\npublic:\n    KeepDisplayOn()\n    {\n        mPrevExecState = ::SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED | ES_CONTINUOUS);\n        ::SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0, &amp;mPrevScreenSaver, 0);\n        ::SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, FALSE, NULL, 0);\n    }\n\n    ~KeepDisplayOn()\n    {\n        ::SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, mPrevScreenSaver, NULL, 0);\n        ::SetThreadExecutionState(mPrevExecState);\n    }\n\nprivate:\n    UINT                                mPrevScreenSaver;\n    EXECUTION_STATE             mPrevExecState;\n};\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>class KeepDisplayOn { public: KeepDisplayOn() { mPrevExecState = ::SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED | ES_CONTINUOUS); ::SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0, &amp;mPrevScreenSaver, 0); ::SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, FALSE, NULL, 0); } ~KeepDisplayOn() { ::SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, mPrevScreenSaver, NULL, 0); ::SetThreadExecutionState(mPrevExecState); } private: UINT mPrevScreenSaver; EXECUTION_STATE mPrevExecState; };<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4671","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4671","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4671"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4671\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4671"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4671"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4671"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}