برای انجام این عملیات چندین راه وجود دارد.یکی از این راهها استفاده از فایل ShutDown.exe است به صورت زیر:
ShutDown
System.Diagnostics.Process.Start("shutdown","-s");
Restart
System.Diagnostics.Process.Start("shutdown","-r");
Log off
System.Diagnostics.Process.Start("shutdown","-l");
برای پاراامترهای بیشتر میتونی از help فایل Shutdown.exe استفاده کنی.
تابع api برای Stand by و Hibernate
تعریف تابع :
[DllImport("powrprof.dll")]
public static extern Int32 SetSuspendState(Int32 HiberNate,Int32 Force,Int32 Disible);
استفاده:
Stand by
SetSuspendState(0,0,0);
Hibernaite
SetSuspendState(1,0,0);
تابع Api برای شات دان Shell32 است.
فایل Shell32.dll را از پوشه System32 ویندوز به Refrence های برنامه اضافه کن بعد از کد زیر استفاده کن.
Shell32.ShellClass s=new Shell32.ShellClass();
s.ShutdownWindows();