While working on the SSD saver (http://masm32.com/board/index.php?topic=9704.0), I stumbled over this:
You can prevent a user from closing the console window by pressing Ctrl C, but you cannot prevent closing the console by clicking into the close box. This is by design - thank you, Redmond. Google for CTRL_CLOSE_EVENT SPI_GETHUNGAPPTIMEOUT to understand why.
MyHandler proc cType ; user presses Ctrl C in console
.if cType==CTRL_C_EVENT || cType==CTRL_CLOSE_EVENT
print cfm$("\nTrying to close the console, right?")
invoke Sleep, 60000 ; one minute - in theory!
or eax, -1
.endif
ret
MyHandler endp
invoke SetConsoleCtrlHandler, MyHandler, 1 ; delays console closing by 5 seconds
Hi,
Try to put the following code before exiting the process:
.Data
szBuffer DB "Press <Enter> to exit", 0
.Code
Invoke GetStdHandle, STD_INPUT_HANDLE
Mov Rcx, Rax
Invoke ReadConsole, Rcx, Addr szBuffer, 21, Addr lpOuput, NULL ; 21 = length of szBuffer
Misunderstanding, Ramon: I don't want to exit...
Oh, I'm sorry. I really misunderstood your post (sometimes I read too fast :sad:)