News:

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

Main Menu

Problem with inkey, it hangs!

Started by DaveG, April 14, 2013, 11:11:52 AM

Previous topic - Next topic

DaveG

Hello, I'm new to masm32.
I actually use RadAsm 2.2.1.6
and Windows 32-Bit of course.

I've been having problems with this code:

Title printing
.386 ;It doesn't changes if I try with .486 either :(
.model flat,stdcall
option casemap:none
include masm32rt.inc
.code
main:
printf("Ocarina",0)
inkey ;Same thing for inkey 0, inkey null, inkey "Any key to exit...".
invoke ExitProcess,0
end main


If I assemble -> Build -> Run, the process (called imprimiendo.exe) just hangs nothing appears in Windows. I've understood that a shell window should appear just waiting for the user to press any key to continue but it just doesn't happens. I don't have any build problems. I have to kill the process via task manager.
If I just erase the inkey line, everything works just fine but no shell windows appears, I've tried going with Tools -> GoTo Dos and run it from there, same thing. :|

Any ideas on how to solve this problem?

hutch--

Dave,

The "inkey" macro should only be used when you do a console build, if its a GUI build there is no way for it to receive any input.

dedndave

build it as a console app
not sure how to do that in RadAsm - probably a selection on the build menu

another way to go is to build it as a windows gui app, and use AllocConsole at the beginning of the program
that will allocate a console that you can use for printf and inkey
        INVOKE  AllocConsole

DaveG

Quote from: hutch-- on April 14, 2013, 11:56:33 AM
Dave,

The "inkey" macro should only be used when you do a console build, if its a GUI build there is no way for it to receive any input.
The thing is, I'm pretty sure a friend has got the same piece of code but it works different on his lap top. I'm going to ask him for the code to see what's going on. Also, how do I make a console build?
Quote from: dedndave on April 14, 2013, 12:10:42 PM
build it as a console app
not sure how to do that in RadAsm - probably a selection on the build menu

another way to go is to build it as a windows gui app, and use AllocConsole at the beginning of the program
that will allocate a console that you can use for printf and inkey
        INVOKE  AllocConsole
Thanks I'm going to check on that later too!

MichaelW

Somewhere in the menu system there should be a way to specify what you are building, in something like Make Options or Build Options, with the choices Windows GUI, Windows Console, Windows DLL, Library, etc.
Well Microsoft, here's another nice mess you've gotten us into.

hutch--

Dave,

On your link command line you should have "/SUBSYSTEM:CONSOLE" to ensure you get a console build.

DaveG

Quote from: hutch-- on April 14, 2013, 06:07:59 PM
Dave,

On your link command line you should have "/SUBSYSTEM:CONSOLE" to ensure you get a console build.
This fixed it, thanks  a lot!!