chore: rework windows signal notify

This commit is contained in:
Louis Seubert 2024-05-10 21:40:41 +02:00
parent b54acec2f2
commit b7517a7fee
Signed by: louis9902
GPG key ID: 4B9DB28F826553BD
3 changed files with 50 additions and 30 deletions

View file

@ -0,0 +1,38 @@
using System.Runtime.InteropServices;
namespace Geekeey.Extensions.Process.Win.Notify;
internal static class Interop
{
// ReSharper disable MemberHidesStaticFromOuterClass
internal static class Libraries
{
internal const string Kernel32 = "kernel32.dll";
}
internal static class Kernel32
{
public delegate bool ConsoleCtrlDelegate(uint dwCtrlEvent);
[DllImport(Libraries.Kernel32)]
[SuppressGCTransition]
internal static extern int GetLastError();
[DllImport(Libraries.Kernel32)]
[SuppressGCTransition]
public static extern bool FreeConsole();
[DllImport(Libraries.Kernel32)]
[SuppressGCTransition]
public static extern bool AttachConsole(uint dwProcessId);
[DllImport(Libraries.Kernel32)]
[SuppressGCTransition]
public static extern bool SetConsoleCtrlHandler(ConsoleCtrlDelegate? handlerRoutine, bool add);
[DllImport(Libraries.Kernel32)]
[SuppressGCTransition]
public static extern bool GenerateConsoleCtrlEvent(uint dwCtrlEvent, uint dwProcessGroupId);
}
}