Use LibraryImport for native APIs
Some checks failed
release Linux / build (Release) (push) Has been cancelled
release macOS / build (Release) (push) Has been cancelled
release Windows desktop (Avalonia UI) / build (Release) (push) Has been cancelled
release Windows / build (Release) (push) Has been cancelled
release Linux / deb (push) Has been cancelled
release Linux / rpm (push) Has been cancelled

This commit is contained in:
2dust 2026-04-06 20:16:30 +08:00
parent f2d929f40e
commit 53041906b3
3 changed files with 12 additions and 9 deletions

View file

@ -5,7 +5,7 @@ using Microsoft.Win32;
namespace v2rayN.Common;
internal static class WindowsUtils
internal static partial class WindowsUtils
{
private static readonly string _tag = "WindowsUtils";
@ -39,8 +39,8 @@ internal static class WindowsUtils
}
}
[DllImport("dwmapi.dll")]
public static extern int DwmSetWindowAttribute(nint hwnd, DWMWINDOWATTRIBUTE attribute, ref int attributeValue, uint attributeSize);
[LibraryImport("dwmapi.dll")]
public static partial int DwmSetWindowAttribute(nint hwnd, DWMWINDOWATTRIBUTE attribute, ref int attributeValue, uint attributeSize);
public static ImageSource IconToImageSource(Icon icon)
{

View file

@ -1,6 +1,6 @@
namespace v2rayN.Manager;
public sealed class HotkeyManager
public sealed partial class HotkeyManager
{
private static readonly Lazy<HotkeyManager> _instance = new(() => new());
public static HotkeyManager Instance = _instance.Value;
@ -165,11 +165,13 @@ public sealed class HotkeyManager
}
}
[DllImport("user32.dll", SetLastError = true)]
private static extern bool RegisterHotKey(nint hWnd, int id, int fsModifiers, int vlc);
[LibraryImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static partial bool RegisterHotKey(nint hWnd, int id, int fsModifiers, int vlc);
[DllImport("user32.dll", SetLastError = true)]
private static extern bool UnregisterHotKey(nint hWnd, int id);
[LibraryImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static partial bool UnregisterHotKey(nint hWnd, int id);
[Flags]
private enum KeyModifiers

View file

@ -8,6 +8,7 @@
<ApplicationIcon>Resources\v2rayN.ico</ApplicationIcon>
<ApplicationManifest>app.manifest</ApplicationManifest>
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>