Question

I want to create two different console windows for two different threads running in a single process. I know that only one console window is allocated per process. So even though I create multiple threads, all the threads use the same console window as STDOUT. What should I do now? Do I need to create two different processes for two different functions? If so how can I access the memory on one process from another?

Was it helpful?

Solution

The AllocConsole function states "A process can be associated with only one console, so the AllocConsole function fails if the calling process already has a console."; a process can ony be attached to a single console. Your desire can only be accomplished by multiple processes. The inter-process communication for such a purpose can be best implemented by using pipes (See "How to spawn console processes with redirected standard handles" as a starter). This way you may open a number of processes, each of which with a console, and "pipe" the I/O from/to them.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top