Stop console window from closing ?

Started by JohnF, December 09, 2008, 11:02:45 AM

Previous topic - Next topic

JohnF

I don't know if this has been discussed before - is there a way to stop a console window from closing - like an IDE does it?

The console app is a third party program that finishes and closes before the output can be read.

Using for example ShellExecute().

Ta!

John

Vortex

Hi John,

Why not to launch the console application from the command prompt?
Code it... That's all...

JohnF

Quote from: Vortex on December 09, 2008, 11:53:17 AM
Hi John,

Why not to launch the console application from the command prompt?

Vortex,

Well, it just isn't going to be started that way.

However as a matter of interest if it was started from the command prompt, is there a way to stop it closing its window?

John

Stefan Pendl

---
Stefan

Proud member of the UltraDefrag Development Team

Vortex

#4
Hi John,

Maybe, you can try to hook the ExitProcess function to stop the console windows from closing.
Code it... That's all...


JohnF

Quote from: Vortex on December 09, 2008, 12:32:07 PM
Hi John,

Maybe, you can try to hook the ExitProcess function to stop the console windows from closing.

Yes, I was looking for an easier way, see above.

Thanks.

John

JohnF



blzbb

another way could be using CreateProcess and use pause command in lpCommandLine like this


CreateProcess(NULL, "program.exe | pause", NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
WaitForSingleObject(pi.hProcess, INFINITE);

JohnF

Quote from: blzbb on December 10, 2008, 09:51:31 AM
another way could be using CreateProcess and use pause command in lpCommandLine like this


CreateProcess(NULL, "program.exe | pause", NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
WaitForSingleObject(pi.hProcess, INFINITE);


Ok, thank you.

John