Funktion für Shutdown, Standby usw.



  • Hi Leute!
    Ich hatte gestern in der MSDN passende Funktionen gefunden, jedoch finde ich sie nicht mehr!
    Ich suche eine funktion zum herunterfahren des systems, neustart, standby ohne shutdown.exe !!!



  • ist ne winapi frage ^^ alle anfragen über sys funktionen am besten ins winapi forum wenns um redmond geht

    ExitWindowsEx(uFlags,res); //res steht für reserviert und kann vollkommen ignoriert werden

    · uFlags
    EWX_FORCE
    Forces processes to terminate. When this flag is set, Windows does not send the messages WM_QUERYENDSESSION and WM_ENDSESSION to the applications currently running in the system. This can cause the applications to lose data. Therefore, you should only use this flag in an emergency.
    EWX_LOGOFF
    Shuts down all processes running in the security context of the process that called the ExitWindowsEx function. Then it logs the user off.
    EWX_POWEROFF
    Shuts down the system and turns off the power. The system must support the power-off feature.
    Windows NT: The calling process must have the SE_SHUTDOWN_NAME privilege. For more information, see the following Remarks section.
    Windows 95: Security privileges are not supported or required.
    EWX_REBOOT
    Shuts down the system and then restarts the system.
    Windows NT: The calling process must have the SE_SHUTDOWN_NAME privilege. For more information, see the following Remarks section.
    Windows 95: Security privileges are not supported or required.
    EWX_SHUTDOWN
    Shuts down the system to a point at which it is safe to turn off the power. All file buffers have been flushed to disk, and all running processes have stopped.



  • Jaaaa! 😃 Danke!!!!!
    Genau die Funktion hatte ich gestern gefunden und heute gesucht 🙂 .
    Sorry....ist schon das falsche Forum, ich musste nur vorhin schnell weg und da hab ichs ins falsche Forum gepostet.



  • Man sollte vielleicht noch erwähnen, dass man bei WinXP ein Recht zum runterfahren/neustarten etc braucht:

    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;
    tkp.Privileges[0].Attributes=SE_PRIVILEGE_ENABLED;
    AdjustTokenPrivileges(hToken,false,&tkp,0,(PTOKEN_PRIVILEGES)NULL,0);
    


  • Dieser Thread wurde von Moderator/in estartu aus dem Forum MFC (Visual C++) in das Forum WinAPI verschoben.

    Im Zweifelsfall bitte auch folgende Hinweise beachten:
    C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?

    Dieses Posting wurde automatisch erzeugt.



  • Man sollte noch erwähnen, dass im Code von ++gast++ jegliche Fehlerbehandlung fehlt und dass man nicht von Rechten spricht, sondern von Privilegien. Und in diesem Fall hat der Benutzer das Privileg schon, es wird nur noch aktiviert.


Anmelden zum Antworten