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. Win32 API and FindWindow

Win32 API and FindWindow

Scheduled Pinned Locked Moved C / C++ / MFC
csharpjsonquestion
3 Posts 3 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.
  • 3 Offline
    3 Offline
    3Dizard
    wrote on last edited by
    #1

    I need a function, which gives me the handle to an active Window. I currently use the FindWindow function, but it also returns handles to already destroyed windows (which come from the same application that ran before and was closed). I found the IsWindow function and currently use it in combination with FindWindow, which looks like the following: private int GetExistingWindow(string cl, string name) { int hWnd; while(true) { if((hWnd = WM.FindWindow(cl, name)) == 0) StartProcess(); if(WM.IsWindow(hWnd)) break; } return hWnd; } questions: 1) Can I do it that way (means returns a second call of FindWindow another handle than the first one or do I always get the same) 2) Is there a better method (single function, etc.) Thanks BTW: The code is written in C#(functions are well implemented), but due to the fact that it is a Win32 API question I decided to post it here.

    M 1 Reply Last reply
    0
    • 3 3Dizard

      I need a function, which gives me the handle to an active Window. I currently use the FindWindow function, but it also returns handles to already destroyed windows (which come from the same application that ran before and was closed). I found the IsWindow function and currently use it in combination with FindWindow, which looks like the following: private int GetExistingWindow(string cl, string name) { int hWnd; while(true) { if((hWnd = WM.FindWindow(cl, name)) == 0) StartProcess(); if(WM.IsWindow(hWnd)) break; } return hWnd; } questions: 1) Can I do it that way (means returns a second call of FindWindow another handle than the first one or do I always get the same) 2) Is there a better method (single function, etc.) Thanks BTW: The code is written in C#(functions are well implemented), but due to the fact that it is a Win32 API question I decided to post it here.

      M Offline
      M Offline
      Mohsen Saad
      wrote on last edited by
      #2

      well the proplem is that in win32 you can not get a valid handle to a window in another application this is some type of protection that windows do to protect applications from affecting each other

      D 1 Reply Last reply
      0
      • M Mohsen Saad

        well the proplem is that in win32 you can not get a valid handle to a window in another application this is some type of protection that windows do to protect applications from affecting each other

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        I'm not sure what you are referring to but FindWindow() does exactly what you indicate is not possible - it returns a handle to a top-level window given either the window's name or class.


        "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

        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