当前位置: 首页>>代码示例>>C++>>正文


C++ SetThreadExecutionState函数代码示例

本文整理汇总了C++中SetThreadExecutionState函数的典型用法代码示例。如果您正苦于以下问题:C++ SetThreadExecutionState函数的具体用法?C++ SetThreadExecutionState怎么用?C++ SetThreadExecutionState使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SetThreadExecutionState函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setKeepAwake

void setKeepAwake(bool awake)
{
    if (awake){
        #if defined(Q_OS_WIN)
            SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_CONTINUOUS);
            
        #elif defined(Q_OS_MAC)
            if(success == kIOReturnSuccess) {
            	
            }else{
                success = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, 
                                                    kIOPMAssertionLevelOn, reasonForActivity, &assertionID);
            }
        #endif
    }else{
        #if defined(Q_OS_WIN)
            SetThreadExecutionState(ES_CONTINUOUS);
            
        #elif defined(Q_OS_MAC)
            if(success == kIOReturnSuccess) {
                IOPMAssertionRelease(assertionID);
                success = kIOReturnError;
                
            }else{
            	
            }
        #endif
    }
}
开发者ID:blake2002,项目名称:gideros,代码行数:29,代码来源:platform-qt.cpp

示例2: wWinMain

int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
                     _In_opt_ HINSTANCE hPrevInstance,
                     _In_ LPWSTR    lpCmdLine,
                     _In_ int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

    // TODO: Place code here.
	SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED | ES_AWAYMODE_REQUIRED);

    HACCEL hAccelTable = LoadAccelerators(hInstance, NULL);

    MSG msg;

    // Main message loop:
    while (GetMessage(&msg, nullptr, 0, 0))
    {
        if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }

	SetThreadExecutionState(ES_CONTINUOUS);

    return (int) msg.wParam;
}
开发者ID:lpestl,项目名称:MouseHop,代码行数:29,代码来源:MouseHopMini.cpp

示例3: client

int client(struct conf *conf, enum action action, int vss_restore, int json)
{
	enum cliret ret=CLIENT_OK;
	
#ifdef HAVE_WIN32
	// prevent sleep when idle
	SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED);
#endif
	
	switch((ret=do_client(conf, action, vss_restore, json)))
	{
		case CLIENT_RECONNECT:
			logp("Re-opening connection to server\n");
			sleep(5);
			ret=do_client(conf, action, vss_restore, json);
		default:
			break;
	}
	
#ifdef HAVE_WIN32
	// allow sleep when idle
	SetThreadExecutionState(ES_CONTINUOUS);
#endif

	// See enum cliret for return codes.
	return (int)ret;
}
开发者ID:jkniiv,项目名称:burp,代码行数:27,代码来源:main.c

示例4: setExecState

/*
 *  Set The Desired Thread Execution State
 */
void setExecState( HWND inHwnd, int stateType )
{
//    char** msg = new char*[3]
//    {
//        "1", "2", "3"
//    };
    switch ( stateType )
    {
        case 0:     // Defaults
            SetThreadExecutionState(ES_CONTINUOUS);
            break;
        case 1:     // Keep System active
            SetThreadExecutionState(
                        ES_SYSTEM_REQUIRED |
                        ES_CONTINUOUS);
            break;
        case 2:     // Keep System and Display active
            SetThreadExecutionState(
                        ES_SYSTEM_REQUIRED |
                        ES_DISPLAY_REQUIRED |
                        ES_CONTINUOUS);
            break;

    }
//    MessageBox(inHwnd, msg[stateType],
//                "standByChBox Status", MB_OK | MB_ICONINFORMATION);
}
开发者ID:ridelub,项目名称:PreventStandBy,代码行数:30,代码来源:main.cpp

示例5: EnableScreenSaver

void EnableScreenSaver(bool enable)
#endif
{
// Inhibit the screensaver. Depending on the operating system this may also
// disable low-power states and/or screen dimming.

#if defined(HAVE_X11) && HAVE_X11
  if (Config::Get(Config::MAIN_DISABLE_SCREENSAVER))
  {
    X11Utils::InhibitScreensaver(win, !enable);
  }
#endif

#ifdef _WIN32
  // Prevents Windows from sleeping, turning off the display, or idling
  if (enable)
  {
    SetThreadExecutionState(ES_CONTINUOUS);
  }
  else
  {
    EXECUTION_STATE should_screen_save =
        Config::Get(Config::MAIN_DISABLE_SCREENSAVER) ? ES_DISPLAY_REQUIRED : 0;
    SetThreadExecutionState(ES_CONTINUOUS | should_screen_save | ES_SYSTEM_REQUIRED);
  }
#endif

#ifdef __APPLE__
  static IOPMAssertionID s_power_assertion = kIOPMNullAssertionID;

  if (Config::Get(Config::MAIN_DISABLE_SCREENSAVER))
  {
    if (enable)
    {
      if (s_power_assertion != kIOPMNullAssertionID)
      {
        IOPMAssertionRelease(s_power_assertion);
        s_power_assertion = kIOPMNullAssertionID;
      }
    }
    else
    {
      CFStringRef reason_for_activity = CFSTR("Emulation Running");
      if (IOPMAssertionCreateWithName(kIOPMAssertionTypePreventUserIdleDisplaySleep,
                                      kIOPMAssertionLevelOn, reason_for_activity,
                                      &s_power_assertion) != kIOReturnSuccess)
      {
        s_power_assertion = kIOPMNullAssertionID;
      }
    }
  }
#endif
}
开发者ID:AdmiralCurtiss,项目名称:dolphin,代码行数:53,代码来源:UICommon.cpp

示例6: BlockShutdown

void PerformanceMonitor::BlockShutdown() {
  if (block_)
    return;

  block_ = true;

  if (!SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED |
                               ES_AWAYMODE_REQUIRED) &&
      !SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED))
    ATLTRACE2(L"Failed to set thread execution state.\n");

  CString text;
  text.LoadString(IDS_NETWORK_ACTIVE);
  ShutdownBlockReasonCreate(message_window_, text);
}
开发者ID:dacci,项目名称:shinobu,代码行数:15,代码来源:performance_monitor.cpp

示例7: vo_w32_control

int vo_w32_control(struct vo *vo, int *events, int request, void *arg)
{
    struct vo_w32_state *w32 = vo->w32;
    switch (request) {
    case VOCTRL_CHECK_EVENTS:
        *events |= vo_w32_check_events(vo);
        return VO_TRUE;
    case VOCTRL_FULLSCREEN:
        vo_w32_fullscreen(vo);
        *events |= VO_EVENT_RESIZE;
        return VO_TRUE;
    case VOCTRL_ONTOP:
        vo_w32_ontop(vo);
        return VO_TRUE;
    case VOCTRL_BORDER:
        vo_w32_border(vo);
        *events |= VO_EVENT_RESIZE;
        return VO_TRUE;
    case VOCTRL_UPDATE_SCREENINFO:
        w32_update_xinerama_info(vo);
        return VO_TRUE;
    case VOCTRL_SET_CURSOR_VISIBILITY:
        w32->cursor_visible = *(bool *)arg;

        if (vo_w32_is_cursor_in_client(vo)) {
            if (w32->cursor_visible)
                SetCursor(LoadCursor(NULL, IDC_ARROW));
            else
                SetCursor(NULL);
        }
        return VO_TRUE;
    case VOCTRL_KILL_SCREENSAVER:
        w32->disable_screensaver = true;
        SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED);
        return VO_TRUE;
    case VOCTRL_RESTORE_SCREENSAVER:
        w32->disable_screensaver = false;
        SetThreadExecutionState(ES_CONTINUOUS);
        return VO_TRUE;
    case VOCTRL_UPDATE_WINDOW_TITLE: {
        wchar_t *title = mp_from_utf8(NULL, (char *)arg);
        SetWindowTextW(w32->window, title);
        talloc_free(title);
        return VO_TRUE;
    }
    }
    return VO_NOTIMPL;
}
开发者ID:benf,项目名称:mpv,代码行数:48,代码来源:w32_common.c

示例8: SetThreadExecutionState

JNIEXPORT void JNICALL Java_sage_PowerManagement_setPowerState0
  (JNIEnv *env, jobject jo, jint powerState)
{
	EXECUTION_STATE es = 0;
	if (powerState & sage_PowerManagement_SYSTEM_POWER)
		es |= ES_SYSTEM_REQUIRED;
	if (powerState & sage_PowerManagement_DISPLAY_POWER)
		es |= ES_DISPLAY_REQUIRED;
	// This one will reset the idle timer so we'll be up for the PM timeout; which is good for when there's user activity
	if (powerState & sage_PowerManagement_USER_ACTIVITY)
		SetThreadExecutionState(es);
	// This one doesn't involve timeouts; it just tells the system if we need display or system power
	es |= ES_CONTINUOUS;
	SetThreadExecutionState(es);

	// See if we need to enable the SS
	if (disabledSS && ((powerState & sage_PowerManagement_DISPLAY_POWER) == 0))
	{
		// Enable the SS
		SystemParametersInfo(SPI_SETSCREENSAVEACTIVE,
		     TRUE,
             0,
             SPIF_SENDWININICHANGE);
		disabledSS = FALSE;
		slog((env, "Enabled SS\r\n"));
	}
	else if (!disabledSS && ((powerState & sage_PowerManagement_DISPLAY_POWER) != 0))
	{
		// Check if the screen saver is enabled, disable it if it is
		BOOL pvParam = 0;
		SystemParametersInfo(SPI_GETSCREENSAVEACTIVE,
                         0,
                         &pvParam,
                         0
                       );
		if (pvParam)
		{
			if (SystemParametersInfo(SPI_SETSCREENSAVEACTIVE,
		         FALSE,
                 0,
                 SPIF_SENDWININICHANGE))
			{
				slog((env, "Disabled SS\r\n"));
				disabledSS = TRUE;
			}
		}
	}
}
开发者ID:BOTCrusher,项目名称:sagetv,代码行数:48,代码来源:PowerManagement.cpp

示例9: WorkerStop

INT WorkerStop()
{
    SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, Worker.prevScreenSaver, NULL, 0);
    SetThreadExecutionState(Worker.prevExecState);

    return TerminateThread(Worker.hThread, 0);
}
开发者ID:lokhman,项目名称:magicworker,代码行数:7,代码来源:main.c

示例10: CloseHandle

CPowerRequest::~CPowerRequest() {
	if (m_Request != INVALID_HANDLE_VALUE) {
		CloseHandle(m_Request);
	} else {
		if (m_bDisplay || m_bSystem) SetThreadExecutionState(ES_CONTINUOUS);
	}
}
开发者ID:exscape,项目名称:foo_simpleserver,代码行数:7,代码来源:CPowerRequest.cpp

示例11: tr

void MainWindow::StartGame(std::unique_ptr<BootParameters>&& parameters)
{
  // If we're running, only start a new game once we've stopped the last.
  if (Core::GetState() != Core::State::Uninitialized)
  {
    if (!RequestStop())
      return;

    // As long as the shutdown isn't complete, we can't boot, so let's boot later
    m_pending_boot = std::move(parameters);
    return;
  }
  // Boot up, show an error if it fails to load the game.
  if (!BootManager::BootCore(std::move(parameters)))
  {
    QMessageBox::critical(this, tr("Error"), tr("Failed to init core"), QMessageBox::Ok);
    return;
  }
  ShowRenderWidget();

#ifdef Q_OS_WIN
  // Prevents Windows from sleeping, turning off the display, or idling
  EXECUTION_STATE shouldScreenSave =
      SConfig::GetInstance().bDisableScreenSaver ? ES_DISPLAY_REQUIRED : 0;
  SetThreadExecutionState(ES_CONTINUOUS | shouldScreenSave | ES_SYSTEM_REQUIRED);
#endif
}
开发者ID:Tinob,项目名称:Ishiiruka,代码行数:27,代码来源:MainWindow.cpp

示例12: OpenInputDesktop

LRESULT CIdlePreventDlg::SendWakeEvent(WPARAM wparam, LPARAM lparam)
{
    // This ensures we only send wake events while the machine isn't locked. Seems Windows queues some events and sometimes they happen at once as soon as you unlock the computer.
	HDESK test = OpenInputDesktop(DF_ALLOWOTHERACCOUNTHOOK, TRUE,DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW |DESKTOP_ENUMERATE | DESKTOP_HOOKCONTROL |DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS |DESKTOP_SWITCHDESKTOP |GENERIC_WRITE);
	if (test != NULL)
	{
        if(RDPFriendlyWakeEnabled) 
        {      
            keybd_event(VK_RSHIFT,0xB6, KEYEVENTF_KEYUP,  0);
        }
        else
        {
            INPUT mouseInput[1];
            mouseInput[0].mi.dx = 0;
            mouseInput[0].mi.dy = 0;
            mouseInput[0].mi.mouseData = 0;
            mouseInput[0].mi.dwFlags = MOUSEEVENTF_MOVE;
            mouseInput[0].mi.time = 0;
            mouseInput[0].mi.dwExtraInfo = NULL;
            SendInput(1, mouseInput, sizeof(mouseInput));
            SetThreadExecutionState(ES_DISPLAY_REQUIRED);
        }
	}
	CloseDesktop(test);
	return 0;
}
开发者ID:enriquein,项目名称:IdlePrevent,代码行数:26,代码来源:IdlePreventDlg.cpp

示例13: ScreensaverAllow

void ScreensaverAllow(bool allow)
{
    EXECUTION_STATE flags = ES_CONTINUOUS;
    if (!allow)
        flags |= ES_DISPLAY_REQUIRED;
    SetThreadExecutionState(flags);
}
开发者ID:revel8n,项目名称:pcsx2,代码行数:7,代码来源:WinMisc.cpp

示例14: winBlockHandler

/* See Porting Layer Definition - p. 6 */
void
winBlockHandler(ScreenPtr pScreen, void *pTimeout)
{
#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
    winScreenPriv(pScreen);
#endif

#ifndef HAS_DEVWINDOWS
    struct timeval **tvp = pTimeout;

    if (*tvp != NULL) {
      if (GetQueueStatus(QS_ALLINPUT | QS_ALLPOSTMESSAGE) != 0) {
        /* If there are still messages to process on the Windows message
           queue, make sure select() just polls rather than blocking.
        */
        (*tvp)->tv_sec = 0;
        (*tvp)->tv_usec = 0;
      }
      else {
        /* Otherwise, lacking /dev/windows, we must wake up again in
           a reasonable time to check the Windows message queue. without
           noticeable delay.
         */
        (*tvp)->tv_sec = 0;
        (*tvp)->tv_usec = 100;
      }
    }
#endif

#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
    /* Signal threaded modules to begin */
    if (pScreenPriv != NULL && !pScreenPriv->fServerStarted) {
        int iReturn;

        winDebug("winBlockHandler - pthread_mutex_unlock()\n");

        /* Flag that modules are to be started */
        pScreenPriv->fServerStarted = TRUE;

        /* Unlock the mutex for threaded modules */
        iReturn = pthread_mutex_unlock(&pScreenPriv->pmServerStarted);
        if (iReturn != 0) {
            ErrorF("winBlockHandler - pthread_mutex_unlock () failed: %d\n",
                   iReturn);
        }
        else {
            winDebug("winBlockHandler - pthread_mutex_unlock () returned\n");
        }
    }
#endif

  /*
    At least one X client has asked to suspend the screensaver, so
    reset Windows' display idle timer
  */
#ifdef SCREENSAVER
  if (screenSaverSuspended)
    SetThreadExecutionState(ES_DISPLAY_REQUIRED);
#endif
}
开发者ID:XQuartz,项目名称:xorg-server,代码行数:61,代码来源:winblock.c

示例15: while

// Windows GUI thread to prevent screen savers or hibernation, and prevent the cursor from getting lost.
int GenericSLMWindowsGUIThread::svc(void)
{
   long i=0;
   while(!stop_)
   {

      ++i;

      if ((i % 900) == 0) {  // Every 30 seconds or so ...
         // ... reset idle clocks to prevent screensaver or hibernation (would appear on SLM).
         SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED);
      }

      if ((i % 30) == 0)
      {
         //FixWindows(hwnd_); // This seems to be too slow. Run in separate thread?
         //SetWindowPos(hwnd_, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); // This seems to be too slow.
      }


      RestrictCursor();

      Sleep(30);
   }

   return 0;
}
开发者ID:bwagjor,项目名称:Thesis,代码行数:28,代码来源:GenericSLM.cpp


注:本文中的SetThreadExecutionState函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。