I want to create a program that can be run as a CLI or GUI application, depending on it Which flag has been passed. Can this be done?
I have found these related questions, but they do not cover my condition completely:
- < / Ul>
indicates that you can not be a program that is not a console program and a non- Console *
Program: The OS needs to know that the subsystem to use before the program starts Once the program has started, it is too late to go back and request another mode.
points This program uses call-to-action technology when it starts running, this program has the effect of allowing the program to write back to the console's console window, which started the program. But the comments of that article tell me as a fatal flaw: The child's process does not really control the console. The console continues to accept input from the original process, and parent
indicates the chain's article.
The first is that devenv uses a really devenv.exe which works through two programs, which is the main GUI program , And the other is devenv.com , which handles console-mode tasks, but if it is non-console-like, it can devenv.exe Moves forward and out for The technique depends on Win32 rules that com files are selected before the exe files when you type a command without the file extension.
There is a simple variation on whether Windows hosts a host of scripts it offers two completely different binaries, wscript.exe and cscript.exe is. Similarly, java.exe for Java console programs and javaw.exe for non-console programs.
The second technique of Junfeng is that ildasm uses the citing process that when the writers of ildasm run in both ways eventually , That's what it does:
- The program has been marked as a console-mode binary, so it always starts with a console, to act as normal Allows input and output redirection for
- If the program does not have a console-mode command-line parameter, then it relaunches itself.
This is not enough to just call Freaconsol
to stop the first instance as a console program, the reason is that the program Started the program, cmd.exe , "knows" that he is starting a console-mode program and he is waiting for the program to stop running. Calling FreConsole
will stop using ildasm , but it can not do start the original process using the console.
Then the first example is automatically restart (with an additional command line parameter, I think). When you call CreateProcess
, there are two different flags to try, none of which will ensure that the second example will not be connected to the parent console. After that, the first example could allow the processing command to resume and command prompt.
The side effect of this technique is that when you start the program from the GUI interface, there will be a console, it will flash momentarily on the screen and then it will disappear.
Junkfeng's article about using editbin to change the program's console-mode flag is a red herring, I think. Your compiler or development winding should provide a setting or option to determine what kind of binary it creates
The bottom line is that you either have two binary You can make a transient flicker of a console window, or . Once you decide that there is less evil, then you have the option of implementation.
*
I non-console GUI because otherwise it is a wrong paradox simply because there is no console in any program This does not mean that there is a GUI in it. A service application is a prime example. Additionally, a program can have and windows console.
Comments
Post a Comment