Exitwindowsex et XP ... merci d'avance

batrasog Messages postés 60 Date d'inscription mercredi 3 mars 2004 Statut Membre Dernière intervention 24 septembre 2004 - 25 avril 2004 à 23:34
batrasog Messages postés 60 Date d'inscription mercredi 3 mars 2004 Statut Membre Dernière intervention 24 septembre 2004 - 26 avril 2004 à 00:24
voilà , le problème est que
ExitwindowsEx (0,0)
ExitwindowsEx (EWX_SHUTDOWN,0)
ou n'importe quelle autre valeurs me fait retourner à l'écran des sessions et ne quitte pas l'ordi !(alors que je pense qu'il devrai s'arreter , même si je n'ai pas essayé sous un autre OS )
merci d'avance :)

4 réponses

BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
25 avril 2004 à 23:46
Tu dois adapter les droits, l'exemple est fourni dans MSDN si je me souviens bien. C'est valable spour tout noyau NT.

ciao...
BruNews, Admin CS, MVP Visual C++
0
batrasog Messages postés 60 Date d'inscription mercredi 3 mars 2004 Statut Membre Dernière intervention 24 septembre 2004
26 avril 2004 à 00:05
escuse moi mais il faut MSDN ou on peut le faire avec les bibliotheques standard (dev c++) ? (bon ok , j'avoue , je viens de commencer il y a pas longtemps :) )
0
BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
26 avril 2004 à 00:09
http://www.msdn.microsoft.com/library/default.asp
Reagrde 'ExitwindowsEx' en bas de page, tu verras un lien qui te conduira sur l'exemple.

ciao...
BruNews, Admin CS, MVP Visual C++
0
batrasog Messages postés 60 Date d'inscription mercredi 3 mars 2004 Statut Membre Dernière intervention 24 septembre 2004
26 avril 2004 à 00:24
merci beaucoup , je vais mettre l'exemple ici :
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/shutting_down.asp

BOOL 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;
}
0
Rejoignez-nous