首页上一页 1 下一页尾页 1 条记录 1/1页
关于关机问题
发表在C#图书答疑
2009-06-05
是否精华
是
否
版块置顶:
是
否
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Management;
namespace shutdown
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
[DllImport("user32.dll", EntryPoint = "ExitWindowsEx", CharSet = CharSet.Ansi)]
private static extern int ExitWindowsEx(int uFlags, int dwReserved);
private void button1_Click(object sender, EventArgs e)
{
ExitWindowsEx(0, 0);
}
private void button3_Click(object sender, EventArgs e)
{
System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
myProcess.StartInfo.FileName = "cmd.exe";
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.RedirectStandardInput = true;
myProcess.StartInfo.RedirectStandardOutput = true;
myProcess.StartInfo.RedirectStandardError = true;
myProcess.StartInfo.CreateNoWindow = true;
myProcess.Start();
myProcess.StandardInput.WriteLine("shutdown -r -t 0");
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button2_Click_1(object sender, EventArgs e)
{
System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
myProcess.StartInfo.FileName = "cmd.exe";
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.RedirectStandardInput = true;
myProcess.StartInfo.RedirectStandardOutput = true;
myProcess.StartInfo.RedirectStandardError = true;
myProcess.StartInfo.CreateNoWindow = true;
myProcess.Start();
myProcess.StandardInput.WriteLine("shutdown -s -t 0");
}
}
}
我是按着你们写的那个写的,在引用里也引用了,可就是不好用我用的是XP系统.
但是我运行你们提供的例子就好了.请您帮我看看我还少什么啊
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Management;
namespace shutdown
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
[DllImport("user32.dll", EntryPoint = "ExitWindowsEx", CharSet = CharSet.Ansi)]
private static extern int ExitWindowsEx(int uFlags, int dwReserved);
private void button1_Click(object sender, EventArgs e)
{
ExitWindowsEx(0, 0);
}
private void button3_Click(object sender, EventArgs e)
{
System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
myProcess.StartInfo.FileName = "cmd.exe";
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.RedirectStandardInput = true;
myProcess.StartInfo.RedirectStandardOutput = true;
myProcess.StartInfo.RedirectStandardError = true;
myProcess.StartInfo.CreateNoWindow = true;
myProcess.Start();
myProcess.StandardInput.WriteLine("shutdown -r -t 0");
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button2_Click_1(object sender, EventArgs e)
{
System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
myProcess.StartInfo.FileName = "cmd.exe";
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.RedirectStandardInput = true;
myProcess.StartInfo.RedirectStandardOutput = true;
myProcess.StartInfo.RedirectStandardError = true;
myProcess.StartInfo.CreateNoWindow = true;
myProcess.Start();
myProcess.StandardInput.WriteLine("shutdown -s -t 0");
}
}
}
我是按着你们写的那个写的,在引用里也引用了,可就是不好用我用的是XP系统.
但是我运行你们提供的例子就好了.请您帮我看看我还少什么啊