Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. ExitWindowsEx Problem!!

ExitWindowsEx Problem!!

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mustafa Demirhan
    wrote on last edited by
    #1

    Hi, In one of my programs, I am trying to shutdown windows. The following code works well under W2k but it does not work under WinME/9x. It starts the shutdown process, it closes all windows and then hides the taskbar but then it stops. Please help. Is there any problems with the code? PS. The reboot operation works well. int CTaskStep::ExecuteShutDown ( CTaskObject *pTask , bool bReboot) { HANDLE hProcess = GetCurrentProcess(); // Is pseudohandle, no close needed HANDLE hToken = NULL; OpenProcessToken(hProcess,TOKEN_ADJUST_PRIVILEGES,&hToken); if ( hToken ) { TOKEN_PRIVILEGES priv_struct; LUID_AND_ATTRIBUTES priv; LUID priv_luid; BOOL bRet; bRet = LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &priv_luid); priv.Attributes = SE_PRIVILEGE_ENABLED; priv.Luid = priv_luid; priv_struct.PrivilegeCount = 1; priv_struct.Privileges->Attributes = SE_PRIVILEGE_ENABLED; priv_struct.Privileges->Luid = priv_luid; bRet = AdjustTokenPrivileges(hToken, FALSE, &priv_struct,NULL,NULL, NULL); CloseHandle( hToken ); } if ( bReboot ) { if(!ExitWindowsEx (EWX_REBOOT | EWX_FORCE,0) ) return MSG_FAILED; } else { if(!ExitWindowsEx(EWX_SHUTDOWN | EWX_POWEROFF | EWX_FORCE, 0)) return MSG_FAILED; } return EX_CONTINUE; } Kind regards Mustafa Demirhan

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups