How to shutdown the computer C# | عمل برنامج غلق الكمبيوتر بعد وقت معين -->

إعلان أدسنس

آخر المواضيع

breaking/كل/9
كل

الاثنين، 16 نوفمبر 2015

5:31 ص

تكبير النص تصغير النص أعادة للحجم الطبيعي

How to shutdown the computer C# 
 عمل برنامج غلق الكمبيوتر بعد وقت معين



اولا نستخدم 
First, add this using :
using System.Diagnostics;

using System.Runtime.InteropServices;

لاغلاق جهاز الكمبيوتر نكتب كود
To shut down , use this code:


Process.Start("shutdown","/s /t 0"); 


لعمل اعادة تشغيل الكمبيوتر
To restart , use this code:
Process.Start("shutdown","/r /t 0");

ولعمل تسجيل الخروج (log off) هنضيف method المشروع بتاعنا
To log off, add this extern method:

[DllImport("user32")]
public static extern bool ExitWindowsEx(uint uFlags, uint dwReason);
ونستخدم هذا الكود 
Then, to log off, invoke the method:
ExitWindowsEx(0,0);


ولعمل lock هنضيف method المشروع بتاعنا
To lock your computer, add this extern method:

[DllImport("user32")]
public static extern void LockWorkStation();

ونستخدم هذا الكود 
Then, to lock, invoke the method:
LockWorkStation(); 


Source code:
download

إرسال تعليق

كل