Sign in to follow this  
Followers 0
FiREFLi

[C#] List of all open windows

9 posts in this topic

How can I get a list of all the windows open using c# on xp?

Share this post


Link to post
Share on other sites

Just to point you in the right direction, I believe you have to use the win api to get the list of open windows. Take a look at EnumWindows in the user32.dll

Share this post


Link to post
Share on other sites

I'm very new to C# and I'm using VS2005 to develop in which is also new to me. How exactly do I look at EnumWindow in user32.dll. Specifically, how to I look in any dll?

Share this post


Link to post
Share on other sites

this is a decent place to start for looking at all the winapi functions: Windows API Reference

Looking at dlls is a different story. I am not that experienced with it, though a tool like dependency walker can help you see some of the functions.

Really the main information you need is in the windows api. All that code is given in C++ and you will have to import the dll and delcare the function in C#, which may be a little advanced for you right now if you are just starting in C#. There are plenty of examples online though, just do some searching.

Share this post


Link to post
Share on other sites

Along these lines, can anyone tell me if there is a way in C# of VB.NET to capture when a window (for any and all apps) opens and closes. I would rather not run a process ever second (or 5, or 10 etc) to see what windows are "now" open and compare.

Thanks

Share this post


Link to post
Share on other sites

You can monitor windows messages, there's a message called WM_CREATE or something, and destroy... google it some more

Share this post


Link to post
Share on other sites
I'm very new to C# and I'm using VS2005 to develop in which is also new to me. How exactly do I look at EnumWindow in user32.dll. Specifically, how to I look in any dll?

http://pinvoke.net/default.aspx/user32.EnumDesktopWindows

There is an example of using user.dll's EnumWindow in C# to list all open windows.

Share this post


Link to post
Share on other sites

Nice link :D Thanks,

Yeah, it's much better to moniter the window events than run a service.

Chris

Share this post


Link to post
Share on other sites

Yeh, you have to use the interop because there is no managed function in the library to accomplish this.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.