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. Problem with CreateProcess and SW_HIDE

Problem with CreateProcess and SW_HIDE

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionannouncement
11 Posts 5 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.
  • T Offline
    T Offline
    Thomas Andersen
    wrote on last edited by
    #1

    Hi.. I've used CreateProcess with SW_HIDE to launch a 3rd party middleware program hidden, but now the 3rd party program has been updated and suddenly my code don't work anymore (the launched window does not hide) ? What could be the reason for that ? I'm totally blank :confused: My code below... (still works wih the old version & other programs) memset(&starttype, 0, sizeof(starttype)); starttype.dwFlags = STARTF_USESHOWWINDOW; starttype.wShowWindow = SW_HIDE; CString appParam = m_cmp + "\\iefcm65n.exe iefcm65n startup /initfile=iefcmn.ini"; CString workdir = m_cmp; if (CreateProcess(NULL,(LPTSTR) (LPCTSTR) appParam,NULL,NULL,FALSE,0,NULL, (LPTSTR) (LPCTSTR) workdir, &starttype, &pinfo)) { prochandle = (long) pinfo.hProcess; threadid = pinfo.dwThreadId; ....

    M J 2 Replies Last reply
    0
    • T Thomas Andersen

      Hi.. I've used CreateProcess with SW_HIDE to launch a 3rd party middleware program hidden, but now the 3rd party program has been updated and suddenly my code don't work anymore (the launched window does not hide) ? What could be the reason for that ? I'm totally blank :confused: My code below... (still works wih the old version & other programs) memset(&starttype, 0, sizeof(starttype)); starttype.dwFlags = STARTF_USESHOWWINDOW; starttype.wShowWindow = SW_HIDE; CString appParam = m_cmp + "\\iefcm65n.exe iefcm65n startup /initfile=iefcmn.ini"; CString workdir = m_cmp; if (CreateProcess(NULL,(LPTSTR) (LPCTSTR) appParam,NULL,NULL,FALSE,0,NULL, (LPTSTR) (LPCTSTR) workdir, &starttype, &pinfo)) { prochandle = (long) pinfo.hProcess; threadid = pinfo.dwThreadId; ....

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      Thomas Andersen wrote: but now the 3rd party program has been updated and suddenly my code don't work anymore You just answered your question - the new program is doing something to override your SW_HIDE request. This might be as simple as them calling ShowWindow() twice, where before they were calling it once. The first ShowWindow() ignores its parameter and uses the SW_HIDE value that you specify, but subsequent calls use the parameter the caller passes. --Mike-- Mister Sparkle is disrespectful to dirt. Homepage | RightClick-Encrypt | 1ClickPicGrabber "You have Erica on the brain" - Jon Sagara to me

      T 1 Reply Last reply
      0
      • M Michael Dunn

        Thomas Andersen wrote: but now the 3rd party program has been updated and suddenly my code don't work anymore You just answered your question - the new program is doing something to override your SW_HIDE request. This might be as simple as them calling ShowWindow() twice, where before they were calling it once. The first ShowWindow() ignores its parameter and uses the SW_HIDE value that you specify, but subsequent calls use the parameter the caller passes. --Mike-- Mister Sparkle is disrespectful to dirt. Homepage | RightClick-Encrypt | 1ClickPicGrabber "You have Erica on the brain" - Jon Sagara to me

        T Offline
        T Offline
        Thomas Andersen
        wrote on last edited by
        #3

        Thanks...:) I take it that there's no way to get past it then ? I can't think of any, but then again I'm not that good at programming ;)

        J 1 Reply Last reply
        0
        • T Thomas Andersen

          Thanks...:) I take it that there's no way to get past it then ? I can't think of any, but then again I'm not that good at programming ;)

          J Offline
          J Offline
          jmkhael
          wrote on last edited by
          #4

          try Finding the window with FindWindow and send it urself a ShowWindow ( SW_HIDE ) u can use the spy++ to get the class name if u need so Papa while (TRUE) Papa.WillLove ( Bebe ) ;

          T 1 Reply Last reply
          0
          • J jmkhael

            try Finding the window with FindWindow and send it urself a ShowWindow ( SW_HIDE ) u can use the spy++ to get the class name if u need so Papa while (TRUE) Papa.WillLove ( Bebe ) ;

            T Offline
            T Offline
            Thomas Andersen
            wrote on last edited by
            #5

            Thanks :) I just tried this right after CreateProcess char wintxt_memory[] = "Client Manager"; char winclass_memory[] = "IEFWINDOW"; LPTSTR wintxt = wintxt_memory; LPTSTR winclass = winclass_memory; HWND h = NULL; h = ::FindWindow(winclass,wintxt); if (h != NULL) ::SetWindowPos(h, HWND_BOTTOM, 0, 0, 0, 0, SWP_HIDEWINDOW); However the window is visible for a brief,flickering and noticable moment and if at all possible I would like to avoid that

            J 1 Reply Last reply
            0
            • T Thomas Andersen

              Thanks :) I just tried this right after CreateProcess char wintxt_memory[] = "Client Manager"; char winclass_memory[] = "IEFWINDOW"; LPTSTR wintxt = wintxt_memory; LPTSTR winclass = winclass_memory; HWND h = NULL; h = ::FindWindow(winclass,wintxt); if (h != NULL) ::SetWindowPos(h, HWND_BOTTOM, 0, 0, 0, 0, SWP_HIDEWINDOW); However the window is visible for a brief,flickering and noticable moment and if at all possible I would like to avoid that

              J Offline
              J Offline
              jmkhael
              wrote on last edited by
              #6

              i guess a better way to tackle this is to hook the ShowWindow api family in the target binary of urs and u chose to handle this function Check Ivo Ivanov article on code project, "Api Hooking revealed" http://www.codeproject.com/system/hooksys.asp?target=hooking%7Crevealed[^] Papa while (TRUE) Papa.WillLove ( Bebe ) ;

              T 1 Reply Last reply
              0
              • J jmkhael

                i guess a better way to tackle this is to hook the ShowWindow api family in the target binary of urs and u chose to handle this function Check Ivo Ivanov article on code project, "Api Hooking revealed" http://www.codeproject.com/system/hooksys.asp?target=hooking%7Crevealed[^] Papa while (TRUE) Papa.WillLove ( Bebe ) ;

                T Offline
                T Offline
                Thomas Andersen
                wrote on last edited by
                #7

                :) Thanks, I'll give it a try.

                C 1 Reply Last reply
                0
                • T Thomas Andersen

                  Hi.. I've used CreateProcess with SW_HIDE to launch a 3rd party middleware program hidden, but now the 3rd party program has been updated and suddenly my code don't work anymore (the launched window does not hide) ? What could be the reason for that ? I'm totally blank :confused: My code below... (still works wih the old version & other programs) memset(&starttype, 0, sizeof(starttype)); starttype.dwFlags = STARTF_USESHOWWINDOW; starttype.wShowWindow = SW_HIDE; CString appParam = m_cmp + "\\iefcm65n.exe iefcm65n startup /initfile=iefcmn.ini"; CString workdir = m_cmp; if (CreateProcess(NULL,(LPTSTR) (LPCTSTR) appParam,NULL,NULL,FALSE,0,NULL, (LPTSTR) (LPCTSTR) workdir, &starttype, &pinfo)) { prochandle = (long) pinfo.hProcess; threadid = pinfo.dwThreadId; ....

                  J Offline
                  J Offline
                  Joseph Dempsey
                  wrote on last edited by
                  #8

                  be warned when working with third party apps ( mainly if you don't know what library ( and language ) created it. We had a major issue awhile back working with apps created in delphi because it turns out the "main" window is handled by a global application object and not allowed available for use by outside apps. Never did get that fixed.... :mad: Joseph Dempsey joseph_r_dempsey@yahoo.com "Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning." --anonymous

                  T 1 Reply Last reply
                  0
                  • T Thomas Andersen

                    :) Thanks, I'll give it a try.

                    C Offline
                    C Offline
                    Chen Venkataraman
                    wrote on last edited by
                    #9

                    You may also want to try not setting the STARTF_USESHOWWINDOW flag in STARTUPINFO structure. Chen Venkataraman

                    T 1 Reply Last reply
                    0
                    • C Chen Venkataraman

                      You may also want to try not setting the STARTF_USESHOWWINDOW flag in STARTUPINFO structure. Chen Venkataraman

                      T Offline
                      T Offline
                      Thomas Andersen
                      wrote on last edited by
                      #10

                      Thanks, but I've used the STARTF_USESHOWWINDOW all the time.

                      1 Reply Last reply
                      0
                      • J Joseph Dempsey

                        be warned when working with third party apps ( mainly if you don't know what library ( and language ) created it. We had a major issue awhile back working with apps created in delphi because it turns out the "main" window is handled by a global application object and not allowed available for use by outside apps. Never did get that fixed.... :mad: Joseph Dempsey joseph_r_dempsey@yahoo.com "Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning." --anonymous

                        T Offline
                        T Offline
                        Thomas Andersen
                        wrote on last edited by
                        #11

                        Thanks, for the warning, I really hope that this won't be one of those that can't be fixed. I'm almost 100% positive that Visual C++ 6.0 was used for this particular app.

                        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