Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Obtaining the HWND of a window

Obtaining the HWND of a window

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hxhl95
    wrote on last edited by
    #1

    Hi all, I am just curious to know if there is a way to find the HWND of a window, given no actual window title and no definitive process name. Although I could get a handle by using the process name, I'd rather not since users might rename the executable file to something else. I am attempting to prevent two instances of one app from being run at once, so I stuck a mutex in. I want my app to send a message to the already running program and close. However, my app needs the HWND of the other running app to send a message to it with SendMessage. The problem is, my app does not have an actual "window", meaning that I can't get it's HWND with FindWindow. It's derived from CFrameWnd and doesn't show up in taskmgr (FindWindow). Any suggestions on how to accomplish this? Thanks in advance :)

    _ S S 3 Replies Last reply
    0
    • H hxhl95

      Hi all, I am just curious to know if there is a way to find the HWND of a window, given no actual window title and no definitive process name. Although I could get a handle by using the process name, I'd rather not since users might rename the executable file to something else. I am attempting to prevent two instances of one app from being run at once, so I stuck a mutex in. I want my app to send a message to the already running program and close. However, my app needs the HWND of the other running app to send a message to it with SendMessage. The problem is, my app does not have an actual "window", meaning that I can't get it's HWND with FindWindow. It's derived from CFrameWnd and doesn't show up in taskmgr (FindWindow). Any suggestions on how to accomplish this? Thanks in advance :)

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      How about saving the HWND into a registry location?

      «_Superman_»

      H 1 Reply Last reply
      0
      • _ _Superman_

        How about saving the HWND into a registry location?

        «_Superman_»

        H Offline
        H Offline
        hxhl95
        wrote on last edited by
        #3

        That'd actually be a good idea. I'll try that. But is there any more...elegant..way to do this? :laugh:

        1 Reply Last reply
        0
        • H hxhl95

          Hi all, I am just curious to know if there is a way to find the HWND of a window, given no actual window title and no definitive process name. Although I could get a handle by using the process name, I'd rather not since users might rename the executable file to something else. I am attempting to prevent two instances of one app from being run at once, so I stuck a mutex in. I want my app to send a message to the already running program and close. However, my app needs the HWND of the other running app to send a message to it with SendMessage. The problem is, my app does not have an actual "window", meaning that I can't get it's HWND with FindWindow. It's derived from CFrameWnd and doesn't show up in taskmgr (FindWindow). Any suggestions on how to accomplish this? Thanks in advance :)

          S Offline
          S Offline
          SandipG
          wrote on last edited by
          #4

          What about using events..??

          Regards, Sandip.

          1 Reply Last reply
          0
          • H hxhl95

            Hi all, I am just curious to know if there is a way to find the HWND of a window, given no actual window title and no definitive process name. Although I could get a handle by using the process name, I'd rather not since users might rename the executable file to something else. I am attempting to prevent two instances of one app from being run at once, so I stuck a mutex in. I want my app to send a message to the already running program and close. However, my app needs the HWND of the other running app to send a message to it with SendMessage. The problem is, my app does not have an actual "window", meaning that I can't get it's HWND with FindWindow. It's derived from CFrameWnd and doesn't show up in taskmgr (FindWindow). Any suggestions on how to accomplish this? Thanks in advance :)

            S Offline
            S Offline
            Stuart Dootson
            wrote on last edited by
            #5

            Rather than a mutex (which I'm presuming has a unique name), you could have a uniquely named bit of shared memory, in which the first process to run could store things like the HWND to post a message to?

            Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

            H 1 Reply Last reply
            0
            • S Stuart Dootson

              Rather than a mutex (which I'm presuming has a unique name), you could have a uniquely named bit of shared memory, in which the first process to run could store things like the HWND to post a message to?

              Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

              H Offline
              H Offline
              hxhl95
              wrote on last edited by
              #6

              I'm probably going with this idea. Thanks a lot. :-D :-D

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups