From 77680e2c02cc14f5c3582736e8e347c0817f9358 Mon Sep 17 00:00:00 2001 From: ChsBuffer <33744752+chsbuffer@users.noreply.github.com> Date: Wed, 16 Dec 2020 16:27:40 +0800 Subject: [PATCH] Fix attach console --- Netch/Netch.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Netch/Netch.cs b/Netch/Netch.cs index 3cefe6f5..93cf2b97 100644 --- a/Netch/Netch.cs +++ b/Netch/Netch.cs @@ -20,8 +20,10 @@ namespace Netch { if (args.Contains("-console")) { - NativeMethods.AllocConsole(); - NativeMethods.AttachConsole(-1); + if (!NativeMethods.AttachConsole(-1)) + { + NativeMethods.AllocConsole(); + } } // 创建互斥体防止多次运行