Is there any way to terminate the console without terminating the program?
Im trying to take an input through the console then get rid of it.
While Im at it, Ive read quite a few overviews, but I cant grasp how to divide.
If someone could write me an example, like dividing 16 by 4, in code.
Thanks a bunch!
Here is a quick demo terminating the console window while the application is running :
.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
include \masm32\include\masm32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\masm32.lib
.data
message1 db 'Press enter to terminate the console',0
message2 db 'Console terminated',0
capt db 'Console demo',0
.data?
buffer db 100 dup(?)
.code
start:
invoke StdOut,ADDR message1
invoke StdIn,ADDR buffer,100
invoke FreeConsole ; This function terminates the console
invoke MessageBox,0,ADDR message2,ADDR capt,MB_OK
invoke ExitProcess,0
END start
[attachment deleted by admin]
Code for 16 divided by 4.
.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
include \masm32\include\masm32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\masm32.lib
.data
answer dd 0
.code
start:
mov edx, 0
mov eax, 16
mov ecx, 4
div ecx
mov answer, eax
invoke ExitProcess,0
end start
If you want to be able to arbitrarily show/hide the console over and over again, the Windows API you need to use are:
AllocConsole, GetStdHandle, FreeConsole