本文介绍了您如何杀死除地雷以外的所有应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在制作一个简单的应用程序,该应用程序应该清除所有正在运行的exe应用程序.我的问题是,除了我的程序外,您如何杀死所有应用程序?

谢谢,


操作系统Windows 7

视觉C#,winform

Hi, I am making a simple application that is supposed to clear all running exe applications. My question is, how do you taskkill all applications except my program?

thanks,


operating system windows 7

visual C#, winform

推荐答案


MR. AngelMendez写道:
MR. AngelMendez wrote:

如何关闭全屏窗口后面的所有窗口?

How about closing any windows that are behind my full screen window?


当然可以,但是为什么呢?它不会解决您的问题.

无论如何,您可以使用Windows API获取桌面的HWND,然后获取其子级,即相对于窗口以特定Z顺序放置的子级.然后,您可以使用System.Diagnostics.Process.MainWindowHandle将此列表与对System.Diagnostics.Process.GetProcesses的调用结果进行比较,请参阅 [ ^ ].

这样,您只能杀死选定的进程.

请参阅:
http://msdn.microsoft.com/zh-我们/library/windows/desktop/ms633504%28v=vs.85%29.aspx [ ^ ](用于查找桌面),
http://msdn.microsoft.com/zh-我们/library/windows/desktop/ms633515%28v=vs.85%29.aspx [ ^ ](查找其子级),
http://msdn.microsoft.com/zh-我们/library/windows/desktop/ms633509%28v=vs.85%29.aspx [ ^ ](以某些Z顺序查找窗口).

如果您需要使用P/Invoke,请参阅:
http://en.wikipedia.org/wiki/P/Invoke [ ^ ],
http://msdn.microsoft.com/library/en-us/vcmxspec/html/vcmg_PlatformInvocationServices.asp [^ ].

此CodeProject文章也可能有用:
基本P/调用 [ ^ ].

—SA


Of course you do it but why? It won''t solve your problem.

Anyway, you can use Windows API to get HWND of a desktop and then its children, those placed in certain Z-order relative to your window. Then you can compare this list with the result of the call to System.Diagnostics.Process.GetProcesses, using System.Diagnostics.Process.MainWindowHandle, please see http://msdn.microsoft.com/en-us/library/system.diagnostics.process.mainwindowhandle.aspx[^].

This way, you can kill only the selected processes.

Please see:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms633504%28v=vs.85%29.aspx[^] (to find desktop),
http://msdn.microsoft.com/en-us/library/windows/desktop/ms633515%28v=vs.85%29.aspx[^] (to find its children),
http://msdn.microsoft.com/en-us/library/windows/desktop/ms633509%28v=vs.85%29.aspx[^] (to find windows in certain Z-order).

If you need to use P/Invoke, please see:
http://en.wikipedia.org/wiki/P/Invoke[^],
http://msdn.microsoft.com/library/en-us/vcmxspec/html/vcmg_PlatformInvocationServices.asp[^].

This CodeProject article can also be useful:
Essential P/Invoke[^].

—SA



这篇关于您如何杀死除地雷以外的所有应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 01:13