Created
September 25, 2017 10:23
-
-
Save hisasann/2dcf55566ff78891ad03ed6322157c54 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[DllImport("kernel32.dll")] | |
public static extern bool AttachConsole(uint dwProcessId); | |
[DllImport("kernel32.dll")] | |
public static extern bool FreeConsole(); | |
private bool writeConsole( string msg ) { | |
if ( !AttachConsole( System.UInt32.MaxValue ) ) { | |
return false; | |
} | |
// stdoutのストリームを取得 | |
System.IO.Stream stream = System.Console.OpenStandardOutput(); | |
System.IO.StreamWriter stdout = new System.IO.StreamWriter( stream ); | |
// 指定された文字列を出力 | |
stdout.Write( msg ); | |
stdout.Flush(); | |
FreeConsole(); | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment