如何通过c#中的代码关闭计算机...

编程入门 行业动态 更新时间:2024-10-25 14:34:25
本文介绍了如何通过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#中的代码关闭计算机...

本文发布于:2023-11-02 13:46:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1552557.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:关闭计算机   代码

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!