Author Topic: Problem with inkey, it hangs!  (Read 5695 times)

DaveG

  • Guest
Problem with inkey, it hangs!
« on: April 14, 2013, 11:11:52 AM »
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:

Code: [Select]
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--

  • Administrator
  • Member
  • ******
  • Posts: 7541
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Problem with inkey, it hangs!
« Reply #1 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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

dedndave

  • Member
  • *****
  • Posts: 8827
  • Still using Abacus 2.0
    • DednDave
Re: Problem with inkey, it hangs!
« Reply #2 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
Code: [Select]
        INVOKE  AllocConsole

DaveG

  • Guest
Re: Problem with inkey, it hangs!
« Reply #3 on: April 14, 2013, 02:12:51 PM »
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?
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
Code: [Select]
        INVOKE  AllocConsole
Thanks I'm going to check on that later too!

MichaelW

  • Global Moderator
  • Member
  • *****
  • Posts: 1209
Re: Problem with inkey, it hangs!
« Reply #4 on: April 14, 2013, 03:29:26 PM »
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--

  • Administrator
  • Member
  • ******
  • Posts: 7541
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Problem with inkey, it hangs!
« Reply #5 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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

DaveG

  • Guest
Re: Problem with inkey, it hangs!
« Reply #6 on: April 15, 2013, 12:58:28 AM »
Dave,

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