mirror of
https://github.com/2dust/v2rayN.git
synced 2026-05-18 23:54:49 +03:00
Use LibraryImport for native APIs
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
<ApplicationIcon>Resources\v2rayN.ico</ApplicationIcon>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -35,4 +36,4 @@
|
||||
<ProjectReference Include="..\ServiceLib\ServiceLib.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user