NO

Author Topic: Wait key sample  (Read 2415 times)

Offline Vortex

  • Member
  • *
  • Posts: 864
    • http://www.vortex.masmcode.com
Wait key sample
« on: August 21, 2024, 10:22:17 PM »
wait_key function adapted from the Masm32 package :

Code: [Select]
.386
.model flat,stdcall
option casemap:none

includelib  \PellesC\lib\Win\kernel32.lib
includelib  msvcrt.lib

include     WaitKeySample.inc

.data

message     db 'This is a wait_key test.',13,10
            db 'Press any key to exit.',13,10,0

f1          db 'Key = %c',0

.code

start:

    invoke  printf,ADDR message

    invoke  wait_key

    invoke  printf,ADDR f1,eax

    invoke  ExitProcess,0

wait_key proc

    invoke  GetStdHandle,STD_INPUT_HANDLE
    invoke  FlushConsoleInputBuffer,eax
@@:
    invoke  Sleep, 1
    invoke  _kbhit
    test    eax, eax
    jz      @b

    call    _getch
    ret

wait_key ENDP

END start
Code it... That's all...