• 0

Get HWND of running process (AppName.exe)


Question

4 answers to this question

Recommended Posts

  • 0
  marcoo said:
I have application running in system tray. I know only its name like (AppName.exe)

How do I get HWND of that application?

BTW FindWindow(NULL, "Window_Title_AppName") doesn't return right handle.

I need it to kill that process with PostMessage(hwnd, WM_CLOSE).

If it doesn't have a form, it wouldn't have an Handle, would it?

  • 0

Depending on how the target application handles thread messages using PostThreadMessage could work.

Other than that, your best (and the easiest too) bet is still FindWindow(Ex). The problem is that "the HWND associated with process X" doesn't exist - a process may have (almost) any number of windows - including zero. A process which registers a tray icon typically has at least one window, but it's not required to IIRC.

You don't really explain what you mean when you say that FindWindow doesn't return the "right" handle. My interpretation is that posting WM_CLOSE doesn't have the desired effect on that particular window. If that is the case, get Spy++ and try to use this method on other windows the process has created.

And before I forget - do you really "need to" use WM_CLOSE? If not, using WM_QUIT is often a lot easier.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Oh man! I can't wait! 😁
    • slowness that result in unproductive, when something was easy fast one click now its basically 2 or 3 clicks and more mouse movement not the end of the world sure but forcing changes for the sake of it for no good reason its one reason why people dont like 11.
    • WhatsApp for Android expands chat themes with 18 new colors by Paul Hill The WhatsApp Beta for Android has just been updated to version 2.25.19.2 (via WABetaInfo) bringing with it 18 new color options, expanding the selection from 20 to 38 colors. This update brings the Android app up to parity with the iOS version, which got this beta update at the start of the month. The expansion of colors will give users greater personalization options for their WhatsApp chats. You can pick the new colors individually per chat or from the settings for every chat, complementing the existing support for various custom backgrounds. How the new chat themes work To set the new colors for individual chats, just open the chat you want to theme, press the three dot menu in the top right and go to themes and change the chat color. To change the theme color across the whole of the app, just go to settings and then select chats and change the chat theme. The new colors are compatible with both light and dark modes and affect the message bubbles. Unlike Messenger where theme changes can be seen by your contact, theme changes in WhatsApp are only visible to the user who applies it. User reception and future outlook Most people running WhatsApp are using the stable version, so you won’t see these new theme colors yet, we will have to wait a bit longer for that. Even if you’re on the beta, the feature may not be available yet as it’s being rolled out. While not a massive change, lots of people like to theme their WhatsApp messages so this change will be welcomed by those that do that. The messaging app scene is very competitive, so this will help Meta retain users on WhatsApp by boosting satisfaction. If you have had a chance to try out the new themes, let us know in the comments what you think!
    • Yup, that thing. Thank you. I found it invaluable for workflow.
    • Windows 11 finally gets a small, but long-requested Windows 10 taskbar feature — and it is not the ability to use small taskbar buttons.
  • Recent Achievements

    • Explorer
      Legend20 went up a rank
      Explorer
    • One Month Later
      jezzzy earned a badge
      One Month Later
    • First Post
      CSpera earned a badge
      First Post
    • One Month Later
      MIR JOHNNY BLAZE earned a badge
      One Month Later
    • Apprentice
      Wireless wookie went up a rank
      Apprentice
  • Popular Contributors

    1. 1
      +primortal
      618
    2. 2
      ATLien_0
      278
    3. 3
      +FloatingFatMan
      178
    4. 4
      Michael Scrip
      150
    5. 5
      Steven P.
      115
  • Tell a friend

    Love Neowin? Tell a friend!