An app with GUI and CUI
-
Hello, I'm making an application, that should use console, when started from a command line and windows otherwise. It has to work in UNIX too, so it must have main(). The way I've done it, works, but I'm not satisfied with it. When I start it from a command line it works properly, but when starting it as GUI it makes a console window first and then GUI. I would like to get rid of the console in GUI version. I've tried to make console disappear using FreeConsole(), but even though I use it as early as possible the console flashes in the beginning. The other solution I've tried is to use linker options '/entry:"main" /subsystem:windows'. This works fine with GUI, but the console version doesn't do anything. I hope someone knows a better way to do it. -Janetta
-
Hello, I'm making an application, that should use console, when started from a command line and windows otherwise. It has to work in UNIX too, so it must have main(). The way I've done it, works, but I'm not satisfied with it. When I start it from a command line it works properly, but when starting it as GUI it makes a console window first and then GUI. I would like to get rid of the console in GUI version. I've tried to make console disappear using FreeConsole(), but even though I use it as early as possible the console flashes in the beginning. The other solution I've tried is to use linker options '/entry:"main" /subsystem:windows'. This works fine with GUI, but the console version doesn't do anything. I hope someone knows a better way to do it. -Janetta
I think that the console creation is perfomed during the C library initialization that is performed by mainCRTStartup before your main function is called. You can found mainCRTStartup code into CRT0.C under /crt/src subdir of VC++ installation (if you installed the C library source code, of course). I never tried to remove the window (I looked at this code only to reduce the size of executables) but you can check the routines called during program startup. There's a good article about C library initialization by Matt Pietrek: http://www.microsoft.com/msj/defaulttop.asp?page=/msj/archive/s569.htm It explain how to reduce executable size but I think it could be helpful also for your pourpouses. Good luck :) -- Looking for a new screen-saver? Try FOYD: http://digilander.iol.it/FOYD
-
Hello, I'm making an application, that should use console, when started from a command line and windows otherwise. It has to work in UNIX too, so it must have main(). The way I've done it, works, but I'm not satisfied with it. When I start it from a command line it works properly, but when starting it as GUI it makes a console window first and then GUI. I would like to get rid of the console in GUI version. I've tried to make console disappear using FreeConsole(), but even though I use it as early as possible the console flashes in the beginning. The other solution I've tried is to use linker options '/entry:"main" /subsystem:windows'. This works fine with GUI, but the console version doesn't do anything. I hope someone knows a better way to do it. -Janetta
Basically, you're screwed. Seriously. :-( The only way to get the stdio handles connected to the console starting the app is by having a main() and the app "tagged" as a console app by the PE flags (linker option /subsystem:console). This is one parts of the baggage we carry from Win16. The default behaviour for a console app to be started is that Windows (I don't know if its the module loader, but I guess it is) allocates a console for a console-tagged app. The only way I know about to change this is to change the flags passed to CreateProcess (to inhibit the creation of the console window). When you have an app that is started by another process (such as Explorer.exe when double-clocking an executable) I can only come to think of hooking (system-wide, loading your DLL for every created process and changing the import translation table) the CreateProcess call to stop it from doing this on a per-application basis. As I initially wrote, you're basically screwed. Sorry...
-
Basically, you're screwed. Seriously. :-( The only way to get the stdio handles connected to the console starting the app is by having a main() and the app "tagged" as a console app by the PE flags (linker option /subsystem:console). This is one parts of the baggage we carry from Win16. The default behaviour for a console app to be started is that Windows (I don't know if its the module loader, but I guess it is) allocates a console for a console-tagged app. The only way I know about to change this is to change the flags passed to CreateProcess (to inhibit the creation of the console window). When you have an app that is started by another process (such as Explorer.exe when double-clocking an executable) I can only come to think of hooking (system-wide, loading your DLL for every created process and changing the import translation table) the CreateProcess call to stop it from doing this on a per-application basis. As I initially wrote, you're basically screwed. Sorry...