In order to print text to the console, we first need to get a handle for the standard output device. Again we use GetStdHandle, but this time with the parameter STD_OUTPUT_HANDLE.
To write to the screen, we first declare and initialise a string of characters that we want to print onscreen, then we call the WriteConsole function.
This function is similar to the ReadConsole function. We pass it five parameters: the handle we just obtained, a pointer to the string that we wish to output, the number of characters of the string that we want to output, a pointer to a double word which can hold the number of characters actually written and finally a zero for a reserved parameter which does nothing.
Here is the program that writes to the screen and then waits for the user to press the enter key.
include '%fasminc%/win32ax.inc' .data inchar DB ? numwritten DD ? numread DD ? outhandle DD ? inhandle DD ? string1 DB "Hello World!" .code start: invoke AllocConsole invoke GetStdHandle,STD_OUTPUT_HANDLE mov [outhandle],eax invoke GetStdHandle,STD_INPUT_HANDLE mov [inhandle],eax invoke WriteConsole,[outhandle],string1,12,numwritten,0 invoke ReadConsole,[inhandle],inchar,1,numread,0 invoke ExitProcess,0 .end startScreen Output Part II