mirror of
https://github.com/netchx/netch.git
synced 2026-03-18 18:13:21 +08:00
feat: -console argument
This commit is contained in:
@@ -66,5 +66,11 @@ namespace Netch
|
||||
|
||||
[DllImport("dnsapi", EntryPoint = "DnsFlushResolverCache")]
|
||||
public static extern uint FlushDNSResolverCache();
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern bool AllocConsole();
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern bool AttachConsole(int dwProcessId);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
@@ -17,6 +18,12 @@ namespace Netch
|
||||
[STAThread]
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
if (args.Contains("-console"))
|
||||
{
|
||||
NativeMethods.AllocConsole();
|
||||
NativeMethods.AttachConsole(-1);
|
||||
}
|
||||
|
||||
// 创建互斥体防止多次运行
|
||||
using (var mutex = new Mutex(false, "Global\\Netch"))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user