News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Terminating Console, not program

Started by sportskid300, August 20, 2007, 04:45:40 PM

Previous topic - Next topic

sportskid300

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!
I can't wait to make windows...

Vortex

#1
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]

dsouza123

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

u

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
Please use a smaller graphic in your signature.