本文介绍了如何通过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 use Process.Start("shutdown","/s 0"); For managed code, try WMI classes. E.g. ManagementClass mcWin32 = new ManagementClass("Win32_OperatingSystem"); Then invoke Win32Shutdown 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#[^]
检查此链接的朋友 www.c-sharpcorner/UploadFile/yuanwang200409/RemoteRestartWindows09252006141003PM/RemoteRestartWindows.aspx [ ^ ] 关闭,重新启动,注销或使用C#锁定您的计算机 [ ^ ] check this links friend www.c-sharpcorner/UploadFile/yuanwang200409/RemoteRestartWindows09252006141003PM/RemoteRestartWindows.aspx[^] Shut Down, Restart, Log off or Lock your computer in C#[^]
更多推荐
如何通过c#中的代码关闭计算机...
发布评论