Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Somebody Know how work the ExitWindowsEx
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00770497
Message ID:
00770532
Vues:
28
Try this code:
#DEFINE EWX_LOGOFF        0 
#DEFINE EWX_SHUTDOWN      1 
#DEFINE EWX_REBOOT        2 
#DEFINE EWX_FORCE         4 
#DEFINE EWX_POWEROFF      8 
#DEFINE EWX_FORCEIFHUNG  16 

DECLARE INTEGER ExitWindowsEx IN user32; 
    INTEGER uFlags, INTEGER dwReserved 

* logoff -- change user 
* = ExitWindowsEx (EWX_LOGOFF, 0) 

* reboot 
= ExitWindowsEx (EWX_REBOOT, 0)
For Windows NT try this code:
DECLARE INTEGER GetLastError IN kernel32 

DECLARE SHORT InitiateSystemShutdown IN advapi32; 
    STRING  lpMachineName,; 
    STRING  lpMessage,; 
    INTEGER dwTimeout,; 
    SHORT   bForceAppsClosed,; 
    SHORT   bRebootAfterShutdown 

IF InitiateSystemShutdown ("", "User time is out", 10, 0, 1) <> 1 
* Common reasons for failure include an invalid 
* or inaccessible computer name or insufficient privilege. 

    *   5 = ERROR_ACCESS_DENIED 
    * 120 = ERROR_CALL_NOT_IMPLEMENTED -- not supported in Win9* 
    ? "Error code:", GetLastError() 
ENDIF
There is another API function allowing to restart Windows:
    DECLARE INTEGER RestartDialog IN shell32; 
        INTEGER hParent, STRING pszPrompt, LONG dwFlags 
If you want to suspend or hibernate your system, here is an API function for this too:
DECLARE INTEGER SetSuspendState IN Powrprof; 
    INTEGER Hibernate, INTEGER ForceCritical,;
    INTEGER DisableWakeEvent 
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform