Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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..
Posted
Updated 12-Apr-13 3:28am
v2
Comments
Steve44 12-Apr-13 5:22am    
Your description makes it sound pretty far out of supported scenarios for the explorer.exe process. I would not be surprised, if the resulting behavior would be "strange", bordering on "unexpected".
vivek.khatri 12-Apr-13 5:32am    
i have seen some snippets that can enumerate all the currently running windows in taskbar, but they just returns the running windows names. They haven't provided how to kill them. They accomplish this by importing user32.dll file..

here is the link i have found :

http://msdntracker.blogspot.in/2008/03/list-currently-opened-windows-with.html

http://blog.cjwdev.co.uk/2010/06/03/get-visible-windows/
CHill60 12-Apr-13 6:45am    
I think you might be confusing people with saying that they are processes starting "under explorer.exe". I think what you want to do is identify windows processes that are started after your program and issue an EndTask (see http://msdn.microsoft.com/en-us/library/windows/desktop/ff468919(v=vs.85).aspx[^])
[EDIT]This is the other link I was looking for http://msdn.microsoft.com/en-us/library/ccf1tfx0.aspx[^]
vivek.khatri 12-Apr-13 9:31am    
please see my updated question, i have explained more clearly about my problem there.. Thanx in advance..
ZurdoDev 12-Apr-13 8:57am    
I don't think you actually want what you say you want, even if it were possible.

1 solution

hi try this,

C#
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
}
 
Share this answer
 
Comments
vivek.khatri 12-Apr-13 10:24am    
but i think this will kill my application too. I want to close all windows explorer windows i.e. My Computer or My Documents or any other folder.

I mean if i open My Computer, it will have the same process ID as the explorer.exe because explorer.exe is the process that provides the GUI for viewing any folder. I want to close all these GUIs, not the explorer.exe process.

Hope you got my concept..

Here is the link to the image, hope that will explain you better...

Image Link : http://sdrv.ms/14hgPLE

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900