The MASM Forum

General => The Campus => Topic started by: Magnum on November 25, 2012, 02:39:30 AM

Title: Code to check if Console
Post by: Magnum on November 25, 2012, 02:39:30 AM
Despite putting CONSOLE in my comments, I often forget to assemble as a console.  :dazzled:

Then I waste time looking for errors caused by assembling a console as a windows based app.

Is there some code I can put in to assemble as a console ?

Thanks.
Title: Re: Code to check if Console
Post by: jj2007 on November 25, 2012, 03:12:20 AM
include \masm32\include\masm32rt.inc

.code
start:
   call AllocConsole
   inkey "Hello"
   exit
end start

Or use RichMasm, it selects automatically the right subsystem ;-)
Title: Re: Code to check if Console
Post by: Magnum on November 25, 2012, 03:33:13 AM
It assembles O.K.

Wouldn't I need to put that code in my bldall.bat ?

Andy
Title: Re: Code to check if Console
Post by: jj2007 on November 25, 2012, 05:59:47 AM
Andy,

A more elegant solution is to put a little proggie into your buildall.bat that determines what you have. I have hacked together something, see attachment. It uses the autodetect keywords of RichMasm (http://www.masmforum.com/board/index.php?topic=9044.0), and I have very rarely had "false positives" ;-)

What you need to do is insert somewhere after the assembly

CheckSusy %1
if errorlevel==1 (
echo CONSOLE
REM link .. /SUBSYSTEM:CONSOLE ...
) else (
echo Windows
REM link .. /SUBSYSTEM:WINDOWS ...
)