Meilleur auteur de réponses
Arrêter l'ordinateur avec c# dans windows 8 (visuel studio 2012)

Question
-
svp quelqu'un m'aider je suis encore débutant dans la langage c# j'ai cette application qui arrête ou redémarrer ou mettre en ville l'ordinateur je veut un code pour faire ces dernières actions et merci :)
- Modifié Dan BajenaruMicrosoft employee, Moderator mardi 19 mars 2013 16:13
Réponses
-
Regardez aussi ce thread:
http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/571a0bc6-3e84-4f7c-af51-20b809246407
C'est impossible pour l'instant avec une appli Windows Store.
Aurel
- Modifié Aurel Bera mardi 19 mars 2013 07:14
- Modifié Dan BajenaruMicrosoft employee, Moderator mardi 19 mars 2013 16:11 mise en page
- Marqué comme réponse Dan BajenaruMicrosoft employee, Moderator mardi 19 mars 2013 16:12
Toutes les réponses
-
Bonjour Rafik,
Voila quelques instructions à tester:
Pour l’arrêter :
ProcessStartInfo startinfo = new ProcessStartInfo(“shutdown.exe”, “-s”); Process.Start(startinfo);
Pour le redémarrer:
ProcessStartInfo startinfo = new ProcessStartInfo(“shutdown.exe”, “-r”); Process.Start(startinfo);
Pour le mettre en veille:
ProcessStartInfo startinfo = new ProcessStartInfo(“shutdown.exe”, “-t”); Process.Start(startinfo);
Explication de deuxième argument:
-s = shutdown -r = restart -t = timed shutdown
Cordialement.chniter sami
- Proposé comme réponse Aurel Bera mercredi 13 mars 2013 07:25
-
sinon tu as ça aussi :
public void Shutdown() { ManagementBaseObject mboShutdown = null; ManagementClass mcWin32 = new ManagementClass("Win32_OperatingSystem"); mcWin32.Get(); // You can't shutdown without security privileges mcWin32.Scope.Options.EnablePrivileges = true; ManagementBaseObject mboShutdownParams = mcWin32.GetMethodParameters("Win32Shutdown"); // Flag 1 means we want to shut down the system. Use "2" to reboot. mboShutdownParams["Flags"] = "1"; mboShutdownParams["Reserved"] = "0"; foreach (ManagementObject manObj in mcWin32.GetInstances()) { mboShutdown = manObj.InvokeMethod("Win32Shutdown", mboShutdownParams, null); } }
- Proposé comme réponse ahmedmahdi lundi 18 mars 2013 12:44
- Non proposé comme réponse ahmedmahdi lundi 18 mars 2013 12:45
-
Bonjour,
Est-ce que vous avez testé les solutions proposées ? Merci de partager avec nous les résultats, afin que d'autres personnes avec le même problème puissent profiter de cette solution.
Cordialement,
Aurel
-
-
-
il rajouter au tous début :
using System.Management;
et l'ajouter aux dossier "références" :
cordialement
- Modifié ahmedmahdi lundi 18 mars 2013 09:46
- Proposé comme réponse ahmedmahdi lundi 18 mars 2013 12:44
- Non proposé comme réponse ahmedmahdi lundi 18 mars 2013 12:45
-
-
-
-
Bonjour
Dans la doc pour System.Diagnostics ici:
http://msdn.microsoft.com/fr-fr/library/windows/apps/hh441592.aspx
Notez que les .NET pour les applications du Windows Store n'incluent pas tous les membres de chaque type. Pour plus d'informations sur les différents types, consultez les rubriques associées. La documentation à propos d'un type indique quels membres sont inclus dans les .NET pour les applications du Windows Store.
Vous devez ouvrir un thread sur le forum dédié aux applications Windows Store :
http://social.msdn.microsoft.com/Forums/fr-FR/winstoreappsfr/threads
-
Regardez aussi ce thread:
http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/571a0bc6-3e84-4f7c-af51-20b809246407
C'est impossible pour l'instant avec une appli Windows Store.
Aurel
- Modifié Aurel Bera mardi 19 mars 2013 07:14
- Modifié Dan BajenaruMicrosoft employee, Moderator mardi 19 mars 2013 16:11 mise en page
- Marqué comme réponse Dan BajenaruMicrosoft employee, Moderator mardi 19 mars 2013 16:12
-