1

I'm trying to develop the software I described in this post:

Get the path of every explorer window with c#

After I better analyzed the problem I found that I need to build a list with the "closed windows" not with the "current open windows".

I want to know if there is a way to catch the close window action and pass the path of that window to a variable in C#.

I appreciate the response had a little explanation and not just the code, to really understand what the code does.

Community
  • 1
  • 1
Memochipan
  • 3,405
  • 5
  • 35
  • 60

1 Answers1

2

Use a CBT hook to receive notification of windows being closed. Note that this would likely be easier from native code. From mananged code you will expend a lot of energy working out p/invoke signatures, marshalling etc.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • Subscribe to the DShellWindowsEvents.WindowRevoked event. – Raymond Chen Dec 20 '11 at 14:29
  • @RaymondChen And how can I do that? Is difficult to find clear information. – Memochipan Nov 03 '12 at 00:20
  • @Memochipan Um, [a search for DShellWindowsEvents](http://stackoverflow.com/search?q=DShellWindowsEvents) quickly turns up [this program](http://stackoverflow.com/questions/239323/internetexplorer-automation-object-performancecounter-not-working). You just need to subscribe to the WindowRevoked event instead of WindowCreated. – Raymond Chen Nov 03 '12 at 06:33