
Launching a console app then getting the handle of the window
Can you call CreateProcess() like:
STARTUPINFO rStartupInfo = {0};
rStartupInfo.dwFlags = STARTF_USESHOWWINDOW;
rStartupInfo.wShowWindow = SW_HIDE;
CreateProcess(..., &rStartupInfo, ...);
or maybe:
CreateProcess(..., CREATE_NO_WINDOW, ...);
Quote:
> I want to write a program that launches an application with the main
window
> hidden but be able to show the window upon the user's request.
> I have had success with GUI applicatins using CreateProcess(...) to launch
> the application and EnumThreadWindows(...) to get the window handle but
this
> approach doesn't work for console programs.
> I have come up with a solution but I want to get some feedback to find out
> if there is a better way.
> New Solution:
> 1) use ShellExecute(...) to launch the application
> 2) call EnumWindows(...)
> 3) in my EnumWindowsProc use GetWindowLong(...) to get the instance handle
> of the current window and compare it with the one returned by
> ShellExecute(...) to find the correct window handle.
> My application takes the path of the app to launch as an argument so the
> title of the new window may differ from time to time ruling out the use of
> FindWindowEx(...) except as a replacement for EnumWindows(...) as a way of
> enumerating the top level windows of the class "ConsoleWindowClass".
> Any suggestions are appreciated
> Daniel