我可以以编程方式关闭所有其他应用程序吗? [英] Can I Close All Other Applications Together Programmatically
本文介绍了我可以以编程方式关闭所有其他应用程序吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法用C#关闭所有其他应用程序。
提前感谢
解决方案
< blockquote>是的......但我不推荐它。
有一个非常非常好的机会你会惹恼别人...
我我没有测试过这个 - 因为我不想关闭我系统上的所有东西 - 但它应该有效:
处理currentApp = Process.GetCurrentProcess();
foreach (处理p Process.GetProcesses())
{
if (p.Id!= currentApp.Id)
{
p.CloseMainWindow();
}
}
不要在调试器下试试这个!
is there any way to close all other applications together using C#.
thanks in advance
解决方案
Yes...but I wouldn't recommend it.
There is a very, very good chance you will annoy the heck out of people...
I have't tested this - because I don't want to close everything on my system - but it should work:
Process currentApp = Process.GetCurrentProcess(); foreach (Process p in Process.GetProcesses()) { if (p.Id != currentApp.Id) { p.CloseMainWindow(); } }Don't try this under the debugger!
这篇关于我可以以编程方式关闭所有其他应用程序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文