Joe Yoyo
Joe Yoyo

Reputation: 1

How do I write a win32 assembly program that outputs to the current console rather than creating a new one?

I'm using this code, compiling with nasm and linking with alink. Whenever I run the resulting exe in bash it spawns a new console separate from the existing command shell. How would I write a program that uses the original console it was executed within rather than spawning a new console?

Upvotes: 0

Views: 77

Answers (1)

Harry Johnston
Harry Johnston

Reputation: 36348

From the code:

;; Since this is a Windows subsystem program, we need to allocate a console,
;; in order to use one. 
call [AllocConsole] 

In other words, it is quite explicitly creating a brand new console. To make it use the existing console, link it as a Console subsystem application rather than a Windows subsystem application, and remove the call to AllocConsole().

Upvotes: 3

Related Questions