[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: WIN32: Spawning a command-line process



> If command-line program is linked with -mswindows

You mean -mwindows (just a typo, I am sure, but in case somebody else
doesn't know).

> then everything works fine,

You mean everything works as expected when your "main" (GUI) app runs
the other program and reads its output? Good, that is as expected.

but I can not execute "prog" in command line.

You mean you can't run the command-line program interactively from a
cmd.exe (or whatever shell) window? True, that's how programs marked
as "GUI" executables work. You have to explicitly redirect its output
to a file, or a pipe, to see it. Run for instance:

  prog | more

or if you are using a Unix-style environment:

  prog | less

If you don't want to do that, your simplest option is to just build
two separate versions of the "prog" program: One linked with
-mwindows, one without. Note that you don't have to change a single
line of code to make it into a "GUI" application, just link it with
-mwindows.

If you read somewhere how "GUI" applications should have WinMain() and
not main(), etc, take that with a large pinch of salt. That is just a
*convention* normally in use (enforced?) in Visual Studio, and just
partly, as far as I can recall, supported by mingw.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]