西西軟件園多重安全檢測下載網(wǎng)站、值得信賴的軟件下載站!
軟件
軟件
文章
搜索

首頁編程開發(fā)其它知識 → 電腦鎖定、注銷、關(guān)機 C#代碼實現(xiàn)

電腦鎖定、注銷、關(guān)機 C#代碼實現(xiàn)

相關(guān)軟件相關(guān)文章發(fā)表評論 來源:本站整理時間:2010/11/29 8:55:54字體大小:A-A+

作者:佚名點擊:491次評論:0次標簽: 注銷 關(guān)機 電腦鎖定

  • 類型:手游電腦版大。26.1M語言:中文 評分:4.2
  • 標簽:
立即下載

c#讓電腦鎖定、注銷、關(guān)機
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
using System.Runtime.InteropServices;
using System.IO;
using System.Threading;
using System.Diagnostics;
//using System.Configuration;
//using System.Xml ;

——————————————————————————————————————————————

// 鎖定計算機.
[DllImport("user32.dll")]
private static extern void LockWorkStation();//須寫extern
private void button1_Click(object sender, EventArgs e)
{
LockWorkStation();
}
//注銷計算機
[DllImport("user32.dll", EntryPoint = "ExitWindowsEx", CharSet = CharSet.Ansi)]
private static extern int ExitWindowsEx(int a,int b);
private void button1_Click(object sender, EventArgs e)
{
ExitWindowsEx(0, 0);
}
//關(guān)閉計算機.
private void button3_Click(object sender, EventArgs e)
{
System.Diagnostics.Process mp = new System.Diagnostics.Process();
mp.StartInfo.FileName = "cmd.exe";
mp.StartInfo.RedirectStandardInput = true;
mp.StartInfo.RedirectStandardOutput = true;
mp.StartInfo.RedirectStandardError = true;
mp.StartInfo.UseShellExecute = false;
mp.StartInfo.CreateNoWindow = true;
mp.Start();//啟動進程
mp.StandardInput.WriteLine("shutdown -s -t 0");//關(guān)機
}
//重啟計算機
private void button3_Click(object sender, EventArgs e)
{
System.Diagnostics.Process mp = new System.Diagnostics.Process();
mp.StartInfo.FileName = "cmd.exe";
mp.StartInfo.RedirectStandardInput = true;
mp.StartInfo.RedirectStandardOutput = true;
mp.StartInfo.RedirectStandardError = true;
mp.StartInfo.UseShellExecute = false;
mp.StartInfo.CreateNoWindow = true;
mp.Start();//啟動進程
mp.StandardInput.WriteLine("shutdown -r -t 0");//重啟
}

LinkDataBase link=new LinkDataBase();string tempTableName="用戶清單";this.ds=link.SelectDataBase(tempStrSQL,tempTableName);this.myTable=ds.Tables[0];你把這個寫到那個單擊事件中試試?

    相關(guān)評論

    閱讀本文后您有什么感想? 已有人給出評價!

    • 8 喜歡喜歡
    • 3 頂
    • 1 難過難過
    • 5 囧
    • 3 圍觀圍觀
    • 2 無聊無聊

    熱門評論

    最新評論

    發(fā)表評論 查看所有評論(0)

    昵稱:
    表情: 高興 可 汗 我不要 害羞 好 下下下 送花 屎 親親
    字數(shù): 0/500 (您的評論需要經(jīng)過審核才能顯示)