如何通过c#中的代码关闭计算机... [英] how to shutdown a computer through code in c#...
本文介绍了如何通过c#中的代码关闭计算机...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道关闭计算机的代码...我想创建一个具有功能plz帮助的应用程序..提前谢谢......
I want to know the code to shutdown a computer...I want to create an app that has ths feature plz help..Thanks in advance...
推荐答案
有很多方法可以做到这一点。
最快的解决方案是使用Process.Start(shutdown, / s 0)
;
对于托管代码,请尝试WMI类。
例如
ManagementClass mcWin32 = new ManagementClass(Win32_OperatingSystem);
然后调用Win32Shutdown
并关闭系统。
您需要一定的权限来访问上述方法。
对于使用非托管代码的解决方案,请尝试
关闭,重新启动,注销或用C#锁定你的计算机 [ ^ ]
There are a number of ways to do this.
The quickest solution is to useProcess.Start("shutdown","/s 0")
;
For managed code, try WMI classes.
E.g.
ManagementClass mcWin32 = new ManagementClass("Win32_OperatingSystem");
Then invokeWin32Shutdown
and shutdown the system.
You would need certain priveleges to access the method above.
For a solution that uses unmanaged code, try
Shut Down, Restart, Log off or Lock your computer in C#[^]
检查此链接的朋友
http://www.c-sharpcorner.com/UploadFile/yuanwang200409/RemoteRestartWindows09252006141003PM/RemoteRestartWindows.aspx [ ^ ]
关闭,重新启动,注销或使用C#锁定您的计算机 [ ^ ]
check this links friend
http://www.c-sharpcorner.com/UploadFile/yuanwang200409/RemoteRestartWindows09252006141003PM/RemoteRestartWindows.aspx[^]
Shut Down, Restart, Log off or Lock your computer in C#[^]
这篇关于如何通过c#中的代码关闭计算机...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文