Problem with CreateProcess and SW_HIDE
-
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; ....
-
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; ....
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 callingShowWindow()
twice, where before they were calling it once. The firstShowWindow()
ignores its parameter and uses theSW_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 -
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 callingShowWindow()
twice, where before they were calling it once. The firstShowWindow()
ignores its parameter and uses theSW_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 meThanks...:) 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 ;)
-
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 ;)
-
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 ) ;
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
-
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
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 ) ;
-
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 ) ;
:) Thanks, I'll give it a try.
-
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; ....
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
-
:) Thanks, I'll give it a try.
You may also want to try not setting the
STARTF_USESHOWWINDOW
flag inSTARTUPINFO
structure. Chen Venkataraman -
You may also want to try not setting the
STARTF_USESHOWWINDOW
flag inSTARTUPINFO
structure. Chen VenkataramanThanks, but I've used the STARTF_USESHOWWINDOW all the time.
-
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
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.