本文整理汇总了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
}
}
示例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;
}
示例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;
}
示例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);
}
示例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
}
示例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);
}
示例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;
}
示例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;
}
}
}
}
示例9: WorkerStop
INT WorkerStop()
{
SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, Worker.prevScreenSaver, NULL, 0);
SetThreadExecutionState(Worker.prevExecState);
return TerminateThread(Worker.hThread, 0);
}
示例10: CloseHandle
CPowerRequest::~CPowerRequest() {
if (m_Request != INVALID_HANDLE_VALUE) {
CloseHandle(m_Request);
} else {
if (m_bDisplay || m_bSystem) SetThreadExecutionState(ES_CONTINUOUS);
}
}
示例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
}
示例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;
}
示例13: ScreensaverAllow
void ScreensaverAllow(bool allow)
{
EXECUTION_STATE flags = ES_CONTINUOUS;
if (!allow)
flags |= ES_DISPLAY_REQUIRED;
SetThreadExecutionState(flags);
}
示例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
}
示例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;
}