簡體   English   中英

如何關閉Win8平板電腦的顯示

[英]How to turn off the display of a Win8 tablet

有沒有一種方法可以關閉Win8 Tablet的顯示而不將其置於睡眠模式?

我使用以下C ++代碼,但此代碼將平板電腦置於睡眠模式:

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);

顯示屏關閉時,我們需要創建一個新的VNC連接。 但是當平板電腦處於睡眠模式時,我們無法做到這一點。 同樣,有關功能的監視器(請參見上面的代碼)在睡眠模式下不起作用...

誰知道我只能關閉Win8 Tablet的顯示嗎?

您可以嘗試使用電源管理API將計算機置於睡眠狀態。 我不確定在計算機處於這種狀態時是否仍可以使用VNC進行連接,但是值得嘗試。

#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;
  }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM