C
C#3mo ago
ChezZ

attach console to a non console application?

Anyone know how to do this?
4 Replies
Jimmacle
Jimmacle3mo ago
AllocConsole function - Windows Console
See reference information about the AllocConsole function, which allocates a new console for the calling process.
Jimmacle
Jimmacle3mo ago
you'll need to call it and related functions with p/invoke for example, declaring this will allow you to call it in C#
[DllImport("kernel32")]
static extern bool AllocConsole();
[DllImport("kernel32")]
static extern bool AllocConsole();
also i don't believe this will automatically set up the Console streams, so you may have to do that yourself if you aren't seeing any output
ChezZ
ChezZ3mo ago
oh yeah I believe you're right I somewhat remember this being the issue i ran into a few nights ago when i tried thank you
jcotton42
jcotton423mo ago
Alternatively, if you always want a console, change the OutputType to Exe. @ChezZ Instead of WinExe.
Want results from more Discord servers?
Add your server