杀死explorer.exe的所有子窗口但不杀死explorer.exe进程 [英] killing all child windows of explorer.exe but not the explorer.exe process

查看:116
本文介绍了杀死explorer.exe的所有子窗口但不杀死explorer.exe进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在.Net Framework 4.0中创建了一个Windows窗体应用程序,它应该跟踪shell进程,即explorer.exe,如果任何窗口或程序在这个explorer.exe进程下启动,我想要立即杀死它,但注意:我不想杀死explorer.exe进程,因为我的其他都市风格的应用程序需要在其中运行。



希望你明白这个问题,如果没有,那么一次又一次地问我。但是请帮我解决这个问题。



让我解释一下我的场景:我正在使用Windows 8.现在当我打开我的电脑或我的文档或任何其他文件夹时在Windows资源管理器下显示,我已经捕获了截图,这是它的链接。现在你可以理解我的问题了。



图片链接



我想阻止用户打开这样的窗口,直到他/她通过我的metro风格应用程序进行身份验证。这意味着当用户进行身份验证时,我的.xml文件中的值会发生变化,根据该值,我将允许用户打开这样的窗口。



抱歉我的英语不好..

i''ve made a windows form application in .Net Framework 4.0 that should keep track on the shell process i.e. "explorer.exe" and if any window or program starts under this "explorer.exe" process, i want to kill it immediately, but NOTE : i don''t want to kill "explorer.exe" process because it is required for my other metro style app to be run within.

Hope u get it the question, if not then ask me again and again. But just help me out from this issue.

let me explain my scenario: I am using Windows 8. Now when i open My Computer or My Documents or any other folder that is shown under Windows Explorer, i have captured a screenshot, here is its link. May be now you all can understand my question.

Image Link

I want to prevent the user from opening such windows, until he/she is authenticated by my metro style application. That means when the user will be authenticated, a value in my .xml file is changed and according to that value, i will allow the user to open such windows.

Sorry for my poor English..

推荐答案

嗨试试这个,



hi try this,

using System.Diagnostics;

Process me = Process.GetCurrentProcess();
foreach (Process p in Process.GetProcesses())
{
    if (P.Id != me.Id) // CHANGE me.Id to explorer PID
        P.CloseMainWindow(); // Sends WM_CLOSE; less gentle methods available too
}


这篇关于杀死explorer.exe的所有子窗口但不杀死explorer.exe进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆