Call AllocConsole and there it is.
You can google the API, it will be described further on msdn.