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. shellexecute get handle ?

shellexecute get handle ?

Scheduled Pinned Locked Moved C / C++ / MFC
jsonhelptutorialquestion
4 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.
  • V Offline
    V Offline
    vantran04
    wrote on last edited by
    #1

    I use function shellexecute (0, "open", "filename", "", "path", SW_SHOW) to execute a program and it runs ok. But I want to get the HWND (handle) of this executed file so that i can hide, minimze, or close it. Please help me how to code (in win32 api) to get the HWND. Thanks.

    V T B 3 Replies Last reply
    0
    • V vantran04

      I use function shellexecute (0, "open", "filename", "", "path", SW_SHOW) to execute a program and it runs ok. But I want to get the HWND (handle) of this executed file so that i can hide, minimze, or close it. Please help me how to code (in win32 api) to get the HWND. Thanks.

      V Offline
      V Offline
      vishalmore
      wrote on last edited by
      #2

      Hi, You can get HWND for the application you are opening through "ShellExecute" using following technique Psedo code: ShellExecute(GetDesktopWindow(), "open", "filename", "", "path", SW_SHOW) EnumChildWindows(GetDesktopWindow(), CallBackChildWindows, lParam) CallBackChildWindows(...) { int iRet; //Get the class name of the window iRet = GetClassName(hwnd,strClassName,..) if(iRet!=0) { //You must be knowing the class name for the application, which you are //opening through the SheeExecute. So match the class name here, once //match the class name exit from this proc. //arrStrClassNames would have all the class names if(strClassName==arrStrClassNames[iIndex]) return false else return true } } Still facing problems ? :cool: Cheers, Vishal

      1 Reply Last reply
      0
      • V vantran04

        I use function shellexecute (0, "open", "filename", "", "path", SW_SHOW) to execute a program and it runs ok. But I want to get the HWND (handle) of this executed file so that i can hide, minimze, or close it. Please help me how to code (in win32 api) to get the HWND. Thanks.

        T Offline
        T Offline
        ThatsAlok
        wrote on last edited by
        #3

        What about Creating Process using CreateProcess Api,Which give Ultimate Control of Process creating Application to control the new born process. have a look at this article:- http://www.codeproject.com/system/newbiespawn.asp[^]

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

        cheers, Alok Gupta VC Forum Q&A :- I/ IV

        1 Reply Last reply
        0
        • V vantran04

          I use function shellexecute (0, "open", "filename", "", "path", SW_SHOW) to execute a program and it runs ok. But I want to get the HWND (handle) of this executed file so that i can hide, minimze, or close it. Please help me how to code (in win32 api) to get the HWND. Thanks.

          B Offline
          B Offline
          Blake Miller
          wrote on last edited by
          #4

          Also look at ShellExecuteEx instead of ShellExecute

          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