diff --git a/YoutubeDl.Wpf/Utils/CtrlCHelper.cs b/YoutubeDl.Wpf/Utils/CtrlCHelper.cs
index 84b6cc8f0..15eb3e9f4 100644
--- a/YoutubeDl.Wpf/Utils/CtrlCHelper.cs
+++ b/YoutubeDl.Wpf/Utils/CtrlCHelper.cs
@@ -8,21 +8,25 @@ namespace YoutubeDl.Wpf.Utils;
/// Related issue: https://github.com/dotnet/runtime/issues/14628
/// Reference: https://stackoverflow.com/questions/283128/how-do-i-send-ctrlc-to-a-process-in-c
///
-internal static class CtrlCHelper
+internal static partial class CtrlCHelper
{
internal const int CTRL_C_EVENT = 0;
- [DllImport("kernel32.dll")]
- internal static extern bool GenerateConsoleCtrlEvent(uint dwCtrlEvent, uint dwProcessGroupId);
+ [LibraryImport("kernel32.dll")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ internal static partial bool GenerateConsoleCtrlEvent(uint dwCtrlEvent, uint dwProcessGroupId);
- [DllImport("kernel32.dll", SetLastError = true)]
- internal static extern bool AttachConsole(uint dwProcessId);
+ [LibraryImport("kernel32.dll", SetLastError = true)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ internal static partial bool AttachConsole(uint dwProcessId);
- [DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
- internal static extern bool FreeConsole();
+ [LibraryImport("kernel32.dll", SetLastError = true)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ internal static partial bool FreeConsole();
- [DllImport("kernel32.dll")]
- internal static extern bool SetConsoleCtrlHandler(ConsoleCtrlDelegate? HandlerRoutine, bool Add);
+ [LibraryImport("kernel32.dll")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ internal static partial bool SetConsoleCtrlHandler(ConsoleCtrlDelegate? HandlerRoutine, [MarshalAs(UnmanagedType.Bool)] bool Add);
internal delegate bool ConsoleCtrlDelegate(uint dwCtrlType);
}
diff --git a/YoutubeDl.Wpf/YoutubeDl.Wpf.csproj b/YoutubeDl.Wpf/YoutubeDl.Wpf.csproj
index 49bd18126..b9f3c7512 100644
--- a/YoutubeDl.Wpf/YoutubeDl.Wpf.csproj
+++ b/YoutubeDl.Wpf/YoutubeDl.Wpf.csproj
@@ -21,6 +21,7 @@
YoutubeDl.Wpf
true
README.md
+ true