This is by no means a simple task, and involves more than a bit of Win32 API hackery.
I did in fact attempt exactly this some time ago and it took a lot of messing around with API calls/argument marshalling to get it working - though I eventually made it quite stable. You can find the code I wrote in the repository for my Windows SSH Server project (specifically the ConsoleDotNet
Visual Studio project). The code for the native C++ DLL should also be included in full.
I believe you should be able to reuse much of that code verbatim (or with only small modifications). It should also be reasonably well commented, if I remember rightly. Still, let me know if you have any trouble understanding it. Good luck!