我的代码如下:
if (frmWeak != null)
{
frmWeak.Close();
}
Frm_main.isGetData = false;
System.Threading.Thread.Sleep(2);
Common.ClosePC();
Application.Exit(); /// <summary>
/// 关闭计算机(通过CMD命令实现)
/// </summary>
public static void ClosePC()
{
//创建访问控制本地系统进程的对象实例
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");
}主要是通过cmd.exe来实现的。高手们来帮帮我吧。
if (frmWeak != null)
{
frmWeak.Close();
}
Frm_main.isGetData = false;
System.Threading.Thread.Sleep(2);
Common.ClosePC();
Application.Exit(); /// <summary>
/// 关闭计算机(通过CMD命令实现)
/// </summary>
public static void ClosePC()
{
//创建访问控制本地系统进程的对象实例
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");
}主要是通过cmd.exe来实现的。高手们来帮帮我吧。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货