c++ - How to turn off the display of a Win8 tablet -
is there way turn off display of win8 tablet without putting tablet in sleep mode?
i use following c++ code, code puts tablet in sleep mode:
const lparam off = 2; // const lparam low = 1; const lparam on = -1; lparam state = 0; if (monitoron) state = on; // set monitor on else state = off; // set monitor off sendmessage(hwnd_broadcast, wm_syscommand, sc_monitorpower, state);
we need create new vnc connection while display off. can't while tablet in sleeping mode. monitor on functionality (see code above) doesn't work in sleeping mode...
anybody knows how can turn off display of win8 tablet?
you can try using power management api keep computer on when put sleep. i'm not sure if can still connect using vnc when computer in state, it's worth try.
#include <atlbase.h> #include <atlutil.h> #include <powrprof.h> #pragma comment(lib, "powrprof.lib") #include <iostream> using namespace std; int main() { try { power_request_context context; context.version = power_request_context_version; context.flags = power_request_context_simple_string; context.reason.simplereasonstring = l"turn screen off"; chandle powerrequest(powercreaterequest(&context)); if(powerrequest == invalid_handle_value) atlthrowlastwin32(); if(!powersetrequest(powerrequest, powerrequestawaymoderequired)) atlthrowlastwin32(); if(!setsuspendstate(false, false, false)) atlthrowlastwin32(); if(!powersetrequest(powerrequest, powerrequestawaymoderequired)) atlthrowlastwin32(); return 0; } catch (const catlexception &e) { wcout << "error: " << atlgeterrordescription(e).getstring() << endl; return e.m_hr; } }
Comments
Post a Comment