process/src/Process.Win.Notify/Interop.cs

41 lines
1.1 KiB
C#
Raw Normal View History

2024-05-10 21:49:43 +02:00
// Copyright (c) The Geekeey Authors
// SPDX-License-Identifier: EUPL-1.2
2024-05-10 21:40:41 +02:00
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);
}
}