[fpc-devel] Dynamic GUI/Console apptype

Mimu Bunnylin mimu at mooncore.eu
Sun Dec 27 02:22:05 CET 2009


Currently, programs for Windows have to be specified as either $APPTYPE  
Console or GUI.

If the user runs a console-mode program from a console, the existing  
console is kept; run outside a console, a new console is created.

If the user runs a GUI-mode program outside a console, no console is  
created, and if run inside a console, the console is immediately released.

But suppose I want a program that will continue running in a console if  
run from a console, but will not automatically create a new one if run  
 from outside a console. (Eg. without command-line arguments, launch the  
program's GUI, otherwise print a list of valid arguments in the console.)

Would this be hard to implement? Presently I have to compile a  
console-mode application, and use the Windows API call FreeConsole to  
eliminate the console if it is not needed. This still makes a useless  
console pop up for a moment, which looks silly. This could be as simple as  
adding a check somewhere in the system unit for whether a console is  
associated with the process or not, and decide the appropriate $APPTYPE at  
runtime.

As far as I can tell, this is an issue with FPC, but the feature request  
was redirected for discussion here.

-Mimu



More information about the fpc-devel mailing list