3 ms·
Microsoft KB article about the problem of console applications quickly flashing a console window and disappearing when launched from Explorer: http://support.m
by kazinator 12y ago
Microsoft KB article about the problem of console applications quickly flashing a console window and disappearing when launched from Explorer:
http://support.microsoft.com/kb/99115 http://support.microsoft.com/kb/99115
TL; DR: an application can guess (via an ugly cursor position based hack) whether it is running in a console window that was allocated just for it by the console startup code (the unwanted case), or whether it is in an inherited window (the intended use case for the code).
A reasonable solution, also, is simply to build two executables: a regular application and a console version of the program. Make the regular application (myprog.exe) attractive for clicking by giving it a icon, in comparison to (myprog-cmdline.exe) which has no icon. myprog.exe just puts up a usage dialog box and quits. Alternatively, they can both be console applications that are almost identical, except that the one with the click-bait icon pauses for console input before quitting.