News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Started from CLI or by double click?

Started by cobold, May 31, 2009, 12:10:34 PM

Previous topic - Next topic

cobold

Greetings,

if you start a console-app by double clicking on it, the console window will vanish when the program exits. For some people that's embarrasing. So it would be nice if your program could find out if it was called from the command line interface or by double click and issue an inkey before exit.
f. ex:

.if <doubleclick>
    inkey
.endif
exit

Result: program issues inkey ONLY if started by double click. Interesting behaviour of GetCommandLine is following:
it returns "C:\<path>\progname" when the program was started by double-click, and
progname only when started from CLI, so
include \masm32\include\masm32rt.inc

.code
start:
    invoke GetCommandLine
    mov esi,eax
    print eax,13,10
    .if byte ptr[esi] == 34
        print "Started by double click",13,10
        inkey
    .else
        print "Started from cmd",9
    .endif
    exit
end start


would do the job.
Any better ideas?

dedndave

        INVOKE  GetStartupInfo
should have something in there

dedndave

you might also try GetConsoleMode - they may be different values at startup (maybe not)

another one is GetConsoleTitle
for CLI, it is "Command Prompt"
if started by explorer, it is the current folder under which the console was opened

one more to try -  GetConsoleWindow