News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Code to check if Console

Started by Magnum, November 25, 2012, 02:39:30 AM

Previous topic - Next topic

Magnum

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.
Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

jj2007

include \masm32\include\masm32rt.inc

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

Or use RichMasm, it selects automatically the right subsystem ;-)

Magnum

It assembles O.K.

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

Andy
Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

jj2007

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, 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 ...
)