capturing window creation and destruction

This is a discussion on capturing window creation and destruction within the Windows Programming forums, part of the Platform Specific Boards category; hello cboard I'm trying to develop an alternative task bar, which will show some additional information about the user's programs ...

  1. #1
    Registered User
    Join Date
    Apr 2011
    Location
    europe
    Posts
    3

    Smile capturing window creation and destruction

    hello cboard

    I'm trying to develop an alternative task bar, which will show some additional information about the user's programs currently running. so my taskbar will for the beginning show the same as the native windows task bar.
    the first challenge is to determine the currently running programs, that have a GUI and are listed on the task bar. I do not need all the daemons and for now I want to ignore the case, where programs are not shown in the task bar directly, but do hide in the system tray.
    I figured out I can find out which programs are currently shown in the task bar, by getting the list of all running processes and checking their window handle hwnd.
    however, I would have to poll the list of processes constantly to discover new windows/processes or find out about closed programs. this would be not very efficient.
    so I thought about listening to system events directly. using a system hook, would it be possible to acquire the information required to find out about newly created or destroyed windows? I'm thinking of WM_CREATE events now.

    or is there any other resource I can exploit to get this information?

    thanks in advance,
    curiosity

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    I can tell you but then I'd have to kill you....

    Unfortunately what you are asking about is also the core functionality in many Viruses.

    Look up SetWindowsHookEX() ... What you want is there. You will have to make a DLL with this in it and you will need the means to communicate with the DLL through messages...

  3. #3
    'Allo, 'Allo, Allo
    Join Date
    Apr 2008
    Posts
    612
    RegisterShellHookWindow. Look out for the HSHELL_WINDOWCREATED and HSHELL_WINDOWDESTROYED notifications.

  4. #4
    Registered User
    Join Date
    Apr 2011
    Location
    europe
    Posts
    3
    Quote Originally Posted by CommonTater View Post
    I can tell you but then I'd have to kill you....

    Unfortunately what you are asking about is also the core functionality in many Viruses.

    Look up SetWindowsHookEX() ... What you want is there. You will have to make a DLL with this in it and you will need the means to communicate with the DLL through messages...
    hello CommonTater,

    thanks for your answer. yeah, I have feared dll injection is the way to go. however, I have never done that before, so it will be fun to code

    @adeyblue, thanks for the link. I see the point, this solution avoids to use the callback procedure.

    curiosity

  5. #5
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by curiosity View Post
    hello CommonTater,
    thanks for your answer. yeah, I have feared dll injection is the way to go. however, I have never done that before, so it will be fun to code
    It was, shall we say, interresting... The first 392,416 tries produced far less than optimal results.

    If you take a look at my Remote Media server application you can see it in action. The server very nicely tracks running programs....

    I would also caution you to check your code with a virus scanner... I ran into a problem with a couple of the more agressive ones freaking out on it.

    All that said... Yes, that does seem the way to go in your case.
    Last edited by CommonTater; 04-06-2011 at 12:18 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 12-16-2008, 02:43 PM
  2. help with basic program
    By JOlszewski in forum C Programming
    Replies: 3
    Last Post: 02-01-2006, 04:19 PM
  3. program not working...please look at this
    By JOlszewski in forum C Programming
    Replies: 3
    Last Post: 01-30-2006, 10:33 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21