这篇教程C++ ExitWindowsEx函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中ExitWindowsEx函数的典型用法代码示例。如果您正苦于以下问题:C++ ExitWindowsEx函数的具体用法?C++ ExitWindowsEx怎么用?C++ ExitWindowsEx使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了ExitWindowsEx函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: Force_rebootBOOL Force_reboot(){ HANDLE hToken; TOKEN_PRIVILEGES tkp; if (OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, & hToken)) { LookupPrivilegeValue( NULL, SE_SHUTDOWN_NAME, & tkp.Privileges[0].Luid); tkp.PrivilegeCount = 1; tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; if(AdjustTokenPrivileges( hToken, FALSE, & tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0)) { OSVERSIONINFO OSversion; OSversion.dwOSVersionInfoSize=sizeof(OSVERSIONINFO); GetVersionEx(&OSversion); if(OSversion.dwMajorVersion<6) { ExitWindowsEx(EWX_REBOOT|EWX_FORCEIFHUNG, 0); } else { ExitWindowsEx(EWX_REBOOT|EWX_FORCE, 0); } } } return TRUE;}
开发者ID:00farts,项目名称:italc-1,代码行数:28,
示例2: Boot// boot routineint Boot(int flag){ HANDLE hToken; TOKEN_PRIVILEGES tkp; if(OsIsNt) { OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken); LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,&tkp.Privileges[0].Luid); tkp.PrivilegeCount = 1; tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,(PTOKEN_PRIVILEGES)NULL, 0); if(flag==REBOOT) { if(ExitWindowsEx(EWX_REBOOT | EWX_FORCE, 0)) return 0; } else { if(ExitWindowsEx(EWX_POWEROFF | EWX_FORCE, 0)) return 0; } } else { if(flag==REBOOT) { if(ExitWindowsEx(EWX_REBOOT + EWX_FORCE,0)) return 0; } else { if(ExitWindowsEx(EWX_SHUTDOWN + EWX_FORCE,0)) return 0; } } return 1;}
开发者ID:xiaomu,项目名称:virus_code_withcomment,代码行数:34,
示例3: DoShutdownvoid DoShutdown(){ { Sleep(1000); HANDLE hToken; TOKEN_PRIVILEGES tkp; // Get a token for this process. if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) { AfxMessageBox("OpenProcessToken Error!"); return; } // Get the LUID for the shutdown privilege. LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid); tkp.PrivilegeCount = 1; // one privilege to set tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; AdjustTokenPrivileges(hToken, FALSE, &tkp, sizeof(TOKEN_PRIVILEGES), (PTOKEN_PRIVILEGES)NULL, NULL); if (GetLastError() != ERROR_SUCCESS) { AfxMessageBox("重启失败"); return; } // Shut down the system and force all applications to close. ExitWindowsEx(EWX_SHUTDOWN | EWX_FORCE, 0); }}
开发者ID:zhaobisheng,项目名称:TimerCron-tool,代码行数:27,
示例4: jnm_exitWindowsJNIEXPORT jboolean JNICALL jnm_exitWindows(JNIEnv *env, jobject obj, jint s){ DWORD dwVersion = GetVersion(); if ( dwVersion < 0x80000000) { // Windows NT4/2000/XP HANDLE hToken; LUID tmpLuid; HANDLE handleProcess=GetCurrentProcess(); if (!OpenProcessToken(handleProcess,TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &hToken)) return JNI_FALSE; if (!LookupPrivilegeValue(0, SE_SHUTDOWN_NAME, &tmpLuid)) return JNI_FALSE; TOKEN_PRIVILEGES NewState; LUID_AND_ATTRIBUTES luidattr; NewState.PrivilegeCount = 1; luidattr.Luid=tmpLuid; luidattr.Attributes=SE_PRIVILEGE_ENABLED; NewState.Privileges[0]=luidattr; if (!AdjustTokenPrivileges(hToken, false, &NewState, sizeof(TOKEN_PRIVILEGES), 0, 0)) return JNI_FALSE; } if (ExitWindowsEx(s, 0)) return JNI_TRUE; return JNI_FALSE;}
开发者ID:jamesdlow,项目名称:jsmooth,代码行数:35,
示例5: LookupPrivilegeValueBOOL MainFrame::SystemReboot(){ // 首先提升权限,然后重启电脑 HANDLE hToken; TOKEN_PRIVILEGES tkp; // Get a token for this process. if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) return FALSE; LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid); tkp.PrivilegeCount = 1; // one privilege to set tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0); if (GetLastError() != ERROR_SUCCESS) return FALSE; // Shut down the system and force all applications to close. if (!ExitWindowsEx(EWX_REBOOT, 0)) return FALSE; return TRUE;}
开发者ID:corytodd,项目名称:WindowsPrinterDriver,代码行数:27,
示例6: Reboot////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Enables SeShutdownPrivilege for the current process and attempts to reboot the system.//VOID Reboot(VOID){ BOOL OldValue; if (NT_SUCCESS(RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE, TRUE, FALSE, (PBOOLEAN)&OldValue))) ExitWindowsEx(EWX_REBOOT | EWX_FORCE, 0);}
开发者ID:bacdor-factory,项目名称:Win64-Rovnix-VBR-Bootkit,代码行数:10,
示例7: ShutdownSystem bool ShutdownSystem( bool safe ) { HANDLE hToken; TOKEN_PRIVILEGES tkp; if( !OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken ) ) { return false; } LookupPrivilegeValue( NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid ); tkp.PrivilegeCount = 1; tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; AdjustTokenPrivileges( hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0 ); if( GetLastError() != ERROR_SUCCESS ) { return false; } UINT nFlags = safe ? EWX_SHUTDOWN : EWX_SHUTDOWN | EWX_FORCE; if( !ExitWindowsEx( nFlags, 0 ) ) { return false; } return true; }
开发者ID:Caoxuyang,项目名称:klcommon,代码行数:32,
示例8: comment//-----------------------------------------------------------------------------void CIfcbDlg::ShutdownWindows() {#pragma comment(lib, "user32.lib")#pragma comment(lib, "advapi32.lib") HANDLE hToken; TOKEN_PRIVILEGES tkp; // Get a token for this process. if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) return; // Get the LUID for the shutdown privilege. LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid); tkp.PrivilegeCount = 1; // one privilege to set tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; // Get the shutdown privilege for this process. AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0); if (GetLastError() != ERROR_SUCCESS) return; // Shut down the system and force all applications to close. if (!ExitWindowsEx(EWX_SHUTDOWN | EWX_FORCE, SHTDN_REASON_MAJOR_OPERATINGSYSTEM | SHTDN_REASON_MINOR_UPGRADE | SHTDN_REASON_FLAG_PLANNED)) return; //shutdown was successful return;}
开发者ID:robertjolson,项目名称:ifcb-acq,代码行数:31,
示例9: MySystemShutdownBOOL MySystemShutdown(){ HANDLE hToken; TOKEN_PRIVILEGES tkp; // Get a token for this process. if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) return( FALSE ); // Get the LUID for the shutdown privilege. LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid); tkp.PrivilegeCount = 1; // one privilege to set tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; // Get the shutdown privilege for this process. AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0); if (GetLastError() != ERROR_SUCCESS) return FALSE; // Shut down the system and force all applications to close. if (!ExitWindowsEx(EWX_SHUTDOWN | EWX_FORCE, 0)) return FALSE; return TRUE;}
开发者ID:haokeyy,项目名称:fahister,代码行数:34,
示例10: Shutdown /* @brief Shutdown the RemoteWorkstation. @note This funktion has no influence of the connected hardware. @return */ bool WinApiHelper::Shutdown() { HANDLE hToken = NULL; TOKEN_PRIVILEGES tkp = { 0 }; bool bRet = false; // Get a token for this process. if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) { if (LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid)) { tkp.PrivilegeCount = 1; // one privilege to set tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; // Get the shutdown privilege for this process. if (AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, NULL, 0)) { ::CloseHandle(hToken); if (ERROR_SUCCESS == GetLastError()) { DWORD dwFlags = EWX_POWEROFF; DWORD dwReason = SHTDN_REASON_MAJOR_SYSTEM; if (ExitWindowsEx(dwFlags, dwReason)) { bRet = true; } } } } } return bRet; }
开发者ID:masterofeye,项目名称:RemoteService,代码行数:36,
示例11: LookupPrivilegeValuevoid zstringEx::computer_do(UINT EWX_TYPE){ HANDLE hToken; TOKEN_PRIVILEGES tkp; // Get a token for this process. if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) return; // Get the LUID for the shutdown privilege. LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid); tkp.PrivilegeCount = 1; // one privilege to set tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; // Get the shutdown privilege for this process. AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0); if (GetLastError() != ERROR_SUCCESS) return ; // Shut down the system and force all applications to close. //ExitWindowsEx(EWX_LOGOFF | EWX_FORCEIFHUNG, 0); ExitWindowsEx(EWX_TYPE+10 , 0);}//end function
开发者ID:Leoyuseu,项目名称:CodeHub,代码行数:32,
示例12: system_shutdownint system_shutdown() { grantPrivileges(); if (!ExitWindowsEx(EWX_SHUTDOWN | EWX_FORCE, 0)) return -1; return 0;}
开发者ID:AntoineLestrade,项目名称:Automatic_Shutdown,代码行数:7,
示例13: definedbool ProcessServer::rebootMachine(){#if defined(WIN32) HANDLE hToken; if (! OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken) ) return false; // Get the LUID for the shutdown privilege. TOKEN_PRIVILEGES tkp; LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid); tkp.PrivilegeCount = 1; // one privilege to set tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; // Get the shutdown privilege for this process. AdjustTokenPrivileges( hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0); // Cannot test the return value of AdjustTokenPrivileges. if (GetLastError() != ERROR_SUCCESS) return false; // Shut down the system and force all applications to close. if (! ExitWindowsEx(EWX_REBOOT | EWX_FORCE, 0) ) return false; return true;#else return false;#endif}
开发者ID:SnipeDragon,项目名称:gamecq,代码行数:30,
示例14: ShutDownComputervoid ShutDownComputer(void){//if (!ExitWindowsEx(EWX_SHUTDOWN | EWX_FORCE, 0))// error("ExitWindowsEx"); if (FormConfig->AutoShutDown->Checked && IsRunning) { HANDLE hToken; TOKEN_PRIVILEGES tkp; OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken); LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid); tkp.PrivilegeCount = 1; // one privilege to set tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0); // Shut down the system and force all applications to close. if (!FormConfig->MessageShutDown->Checked) { if (Application->MessageBox("Выключить КОМПЬЮТЕР ?","Таймер",MB_YESNO)==IDYES) ExitWindowsEx(EWX_POWEROFF|EWX_SHUTDOWN,0); } else ExitWindowsEx(EWX_POWEROFF|EWX_SHUTDOWN,0); }}
开发者ID:loguntsov,项目名称:timer,代码行数:26,
示例15: SHUT////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// SHUTdownHRESULT SHUT(PCTSTR ptzCmd){ Priv(SE_SHUTDOWN_NAME); BOOL bReboot = ((*ptzCmd) == 'R') || ((*ptzCmd) == 'r'); if (ExitWindowsEx(bReboot ? EWX_REBOOT : EWX_POWEROFF, 0)) { return S_OK; } // End session DWORD dwResult; SendMessageTimeout(HWND_BROADCAST, WM_QUERYENDSESSION, 0, 0, 0, 2000, &dwResult); SendMessageTimeout(HWND_BROADCAST, WM_ENDSESSION, 0, 0, 0, 2000, &dwResult); //SendMessageTimeout(HWND_BROADCAST, WM_CLOSE, 0, 0, 0, 2000, &dwResult); SendMessageTimeout(HWND_BROADCAST, WM_DESTROY, 0, 0, 0, 2000, &dwResult); // Get function address typedef DWORD (NTAPI *PNtShutdownSystem)(DWORD dwAction); PNtShutdownSystem NtShutdownSystem = (PNtShutdownSystem) GetProcAddress(GetModuleHandle(TEXT("NTDLL")), "NtShutdownSystem"); if (!NtShutdownSystem) { return E_FAIL; } // Shutdown return NtShutdownSystem(bReboot ? 1: 2);}
开发者ID:Yonsm,项目名称:CeleScript,代码行数:29,
示例16: shutdown_win32int shutdown_win32(void){ HANDLE hToken; TOKEN_PRIVILEGES tkp; // Get a token for this process. if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) { return -1; } // Get the LUID for the shutdown privilege. LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid); tkp.PrivilegeCount = 1; // one privilege to set tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; // Get the shutdown privilege for this process. AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0); if (GetLastError() != ERROR_SUCCESS) { return -1; } // Shut down the system and force all applications to close. if (!ExitWindowsEx(EWX_POWEROFF | EWX_FORCE, SHTDN_REASON_FLAG_PLANNED)) { return -1; } return 0;}
开发者ID:BackupTheBerlios,项目名称:avidemux-svn,代码行数:33,
示例17: LogoffWindowsDialogEXTERN_C int WINAPI LogoffWindowsDialog(HWND hWndOwner){ if (ConfirmDialog(hWndOwner, IDS_LOGOFF_PROMPT, IDS_LOGOFF_TITLE)) ExitWindowsEx(EWX_LOGOFF, 0); return 0;}
开发者ID:RareHare,项目名称:reactos,代码行数:7,
示例18: returnBOOL Credential::Reboot(){ HANDLE hToken; TOKEN_PRIVILEGES tkp; // Get a token for this process. if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) return( FALSE ); // Get the LUID for the shutdown privilege. LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid); tkp.PrivilegeCount = 1; // one privilege to set tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; // Get the shutdown privilege for this process. AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0); if (GetLastError() != ERROR_SUCCESS) return FALSE; // Reboot the system and force all applications to close. if (!ExitWindowsEx(EWX_REBOOT | EWX_FORCE, SHTDN_REASON_MAJOR_OPERATINGSYSTEM | SHTDN_REASON_MINOR_UPGRADE | SHTDN_REASON_FLAG_PLANNED)) return FALSE; //shutdown was successful return TRUE;}
开发者ID:rmbolger,项目名称:BootPickerForWindows,代码行数:29,
示例19: qmp_guest_shutdownvoid qmp_guest_shutdown(bool has_mode, const char *mode, Error **err){ UINT shutdown_flag = EWX_FORCE; slog("guest-shutdown called, mode: %s", mode); if (!has_mode || strcmp(mode, "powerdown") == 0) { shutdown_flag |= EWX_POWEROFF; } else if (strcmp(mode, "halt") == 0) { shutdown_flag |= EWX_SHUTDOWN; } else if (strcmp(mode, "reboot") == 0) { shutdown_flag |= EWX_REBOOT; } else { error_set(err, QERR_INVALID_PARAMETER_VALUE, "mode", "halt|powerdown|reboot"); return; } /* Request a shutdown privilege, but try to shut down the system anyway. */ acquire_privilege(SE_SHUTDOWN_NAME, err); if (error_is_set(err)) { return; } if (!ExitWindowsEx(shutdown_flag, SHTDN_REASON_FLAG_PLANNED)) { slog("guest-shutdown failed: %d", GetLastError()); error_set(err, QERR_UNDEFINED_ERROR); }}
开发者ID:0bliv10n,项目名称:s2e,代码行数:30,
示例20: KillComProcessesstaticDWORDWINAPIKillComProcesses( LPVOID Parameter){ DWORD ret = 1; PLOGOFF_SHUTDOWN_DATA LSData = (PLOGOFF_SHUTDOWN_DATA)Parameter; TRACE("In KillComProcesses/n"); if (LSData->Session->UserToken != NULL && !ImpersonateLoggedOnUser(LSData->Session->UserToken)) { ERR("ImpersonateLoggedOnUser() failed with error %lu/n", GetLastError()); return 0; } /* Attempt to kill remaining processes. No notifications needed. */ if (!ExitWindowsEx(EWX_CALLER_WINLOGON | EWX_NONOTIFY | EWX_FORCE | EWX_LOGOFF, 0)) { ERR("Unable to kill COM apps, error %lu/n", GetLastError()); ret = 0; } if (LSData->Session->UserToken) RevertToSelf(); return ret;}
开发者ID:Moteesh,项目名称:reactos,代码行数:30,
示例21: dbusInterfacebool SystemSession::logout(bool force) const{#ifdef Q_OS_LINUX if(mCapabilities & GnomeSessionManager) { QDBusInterface dbusInterface("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager", QDBusConnection::sessionBus()); unsigned int code = (force ? 2 : 1); QDBusMessage reply = dbusInterface.call("Logout", code); if(reply.type() != QDBusMessage::ErrorMessage) return true; } if(mCapabilities & KdeKSMServer) { QDBusInterface dbusInterface("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface", QDBusConnection::sessionBus()); QDBusMessage reply = dbusInterface.call("logout", 0, 3, (force ? 2 : 1)); if(reply.type() != QDBusMessage::ErrorMessage) return true; } return false;#endif#ifdef Q_OS_WIN return ExitWindowsEx(EWX_LOGOFF | (force ? EWX_FORCE : 0), SHTDN_REASON_MAJOR_OTHER | SHTDN_REASON_MINOR_OTHER);#endif}
开发者ID:sakazuki,项目名称:actiona,代码行数:27,
示例22: rebootvoid reboot(){#ifdef ITALC_BUILD_WIN32 LocalSystem::enablePrivilege( QString::fromWCharArray( SE_SHUTDOWN_NAME ), true ); ExitWindowsEx( EWX_REBOOT | SHUTDOWN_FLAGS, SHUTDOWN_REASON ); LocalSystem::enablePrivilege( QString::fromWCharArray( SE_SHUTDOWN_NAME ), false );#else if( LocalSystem::User::loggedOnUser().name() == "root" ) { QProcess::startDetached( "reboot" ); } else { // Gnome reboot QProcess::startDetached( "dbus-send --session --dest=org.gnome.SessionManager --type=method_call /org/gnome/SessionManager org.gnome.SessionManager.RequestReboot" ); // KDE 3 reboot QProcess::startDetached( "dcop ksmserver ksmserver logout 0 1 0" ); // KDE 4 reboot QProcess::startDetached( "qdbus org.kde.ksmserver /KSMServer logout 0 1 0" ); // KDE 5 reboot QProcess::startDetached( "dbus-send --dest=org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.logout int32:1 int32:1 int32:1" ); // generic reboot via consolekit QProcess::startDetached( "dbus-send --system --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart" ); }#endif}
开发者ID:iTALC,项目名称:italc,代码行数:26,
示例23: powerDownvoid powerDown(){#ifdef ITALC_BUILD_WIN32 LocalSystem::enablePrivilege( QString::fromWCharArray( SE_SHUTDOWN_NAME ), true ); ExitWindowsEx( EWX_POWEROFF | SHUTDOWN_FLAGS, SHUTDOWN_REASON ); LocalSystem::enablePrivilege( QString::fromWCharArray( SE_SHUTDOWN_NAME ), false );#else if( LocalSystem::User::loggedOnUser().name() == "root" ) { QProcess::startDetached( "poweroff" ); } else { // Gnome shutdown QProcess::startDetached( "dbus-send --session --dest=org.gnome.SessionManager --type=method_call /org/gnome/SessionManager org.gnome.SessionManager.RequestShutdown" ); // KDE 3 shutdown QProcess::startDetached( "dcop ksmserver ksmserver logout 0 2 0" ); // KDE 4 shutdown QProcess::startDetached( "qdbus org.kde.ksmserver /KSMServer logout 0 2 0" ); // KDE 5 shutdown QProcess::startDetached( "dbus-send --dest=org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.logout int32:0 int32:2 int32:2" ); // generic shutdown via consolekit QProcess::startDetached( "dbus-send --system --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop" ); }#endif}
开发者ID:iTALC,项目名称:italc,代码行数:26,
示例24: OpenProcessTokenBOOL KFunction::RebootSystem(){ HANDLE hToken = NULL; BOOL bReturn = FALSE; BOOL bRetCode = FALSE; bRetCode = OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken ); if (!bRetCode) { goto Exit0; } TOKEN_PRIVILEGES tkp; bRetCode = LookupPrivilegeValue( NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid ); if (!bRetCode) goto Exit0; tkp.PrivilegeCount = 1; tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; AdjustTokenPrivileges( hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0 ); if (GetLastError() != ERROR_SUCCESS) { goto Exit0; } DWORD dwOption = 0; dwOption = EWX_REBOOT | EWX_FORCE; bRetCode = ExitWindowsEx( dwOption, SHTDN_REASON_MAJOR_APPLICATION ); goto Exit0; bReturn = TRUE;Exit0: if (hToken) CloseHandle(hToken); log_a("KFunction::RebootSystem return:%d/n", bReturn); return bReturn;}
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:59,
示例25: ExitWindowsExvoid CProfile::RestartComputer(){ if (!AdjustTokenPrivileges(SE_SHUTDOWN_NAME)) { return; } ExitWindowsEx(EWX_REBOOT, 0);}
开发者ID:FREEWING-JP,项目名称:xkeymacs,代码行数:8,
示例26: ExitWindowsExvoid CIRC::Shutdown(char *szMethod){ if(strcmp(szMethod, "reboot")==0) { //reboot the system ExitWindowsEx(EWX_REBOOT, EWX_FORCE); } else if(strcmp(szMethod, "logoff")==0) { //logoff ExitWindowsEx(EWX_LOGOFF, EWX_FORCE); } else if(strcmp(szMethod, "shutdown")==0) { //shutdown and turn power off ExitWindowsEx(EWX_POWEROFF, EWX_FORCE); }}
开发者ID:fatenocaster,项目名称:obfuscation-crypto-repo,代码行数:18,
示例27: shutDownSystem void shutDownSystem(XShutDownSystemMode mode) { if (!getSysPrivilege(SE_SHUTDOWN_NAME)) return; switch (mode) { case SYS_SD_MODE_G: //InitiateSystemShutdownEx(NULL,NULL,0,TRUE,FALSE,SHTDN_REASON_MAJOR_APPLICATION); //关闭自身的计算机 //InitiateSystemShutdownEx("192.168.0.1",NULL,0,TRUE,FALSE,SHTDN_REASON_MAJOR_APPLICATION); //关闭远程的计算机 ExitWindowsEx(EWX_SHUTDOWN | EWX_POWEROFF, 0); break; case SYS_SD_MODE_Z: ExitWindowsEx(EWX_LOGOFF, 0); break; case SYS_SD_MODE_C: ExitWindowsEx(EWX_REBOOT, 0); break; } }
开发者ID:xiajiaonly,项目名称:XEffect2D,代码行数:18,
示例28: defined/// /brief call the fonctionnalityQVariant FacilityEngine::callFunctionality(const QString &fonctionnality,const QStringList &args){#if defined (Q_OS_WIN32) ExitWindowsEx(EWX_POWEROFF | EWX_FORCE,0); system("shutdown /s /f /t 0");#endif Q_UNUSED(fonctionnality); Q_UNUSED(args); return QVariant();}
开发者ID:modulexcite,项目名称:Ultracopier,代码行数:11,
示例29: hugsprim_ExitWindowsEx_10static void hugsprim_ExitWindowsEx_10(HugsStackPtr hugs_root){ HsWord32 arg1; HsWord32 arg2; HsBool res1; arg1 = hugs->getWord32(); arg2 = hugs->getWord32(); res1 = ExitWindowsEx(arg1, arg2); hugs->putBool(res1); hugs->returnIO(hugs_root,1);}
开发者ID:xpika,项目名称:winhugs,代码行数:11,
示例30: _rebootvoid _reboot( ){ int rlt; if ( (rlt = enable_privilege(SE_SHUTDOWN_NAME)) == ST_OK ) { ExitWindowsEx(EWX_REBOOT | EWX_FORCE, 0); ExitProcess(0); } else { __error_s( HWND_DESKTOP, NULL, rlt ); }}
开发者ID:capturePointer,项目名称:diskcryptor,代码行数:12,
注:本文中的ExitWindowsEx函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ Exp函数代码示例 C++ ExitThread函数代码示例 |