改用LibraryImport
This commit is contained in:
parent
8f86f5231a
commit
f03cb346f9
@ -26,11 +26,13 @@ namespace 鼠标连点器
|
|||||||
private const int VK_F8 = 0x77; // Virtual key code for F8
|
private const int VK_F8 = 0x77; // Virtual key code for F8
|
||||||
|
|
||||||
// Importing necessary Windows API functions
|
// Importing necessary Windows API functions
|
||||||
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
|
[LibraryImport("user32.dll", EntryPoint = "mouse_event")]
|
||||||
public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
|
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvStdcall) })]
|
||||||
|
private static partial void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
[LibraryImport("user32.dll", EntryPoint = "GetCursorPos")]
|
||||||
static extern bool GetCursorPos(out POINT lpPoint);
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
private static partial bool GetCursorPos(out POINT lpPoint);
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct POINT
|
public struct POINT
|
||||||
@ -39,18 +41,18 @@ namespace 鼠标连点器
|
|||||||
public int Y;
|
public int Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
[LibraryImport("user32.dll", EntryPoint = "SetWindowsHookExW", SetLastError = true)]
|
||||||
private static extern IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId);
|
private static partial IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId);
|
||||||
|
|
||||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
[LibraryImport("user32.dll", EntryPoint = "UnhookWindowsHookEx", SetLastError = true)]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
private static extern bool UnhookWindowsHookEx(IntPtr hhk);
|
private static partial bool UnhookWindowsHookEx(IntPtr hhk);
|
||||||
|
|
||||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
[LibraryImport("user32.dll", EntryPoint = "CallNextHookEx", SetLastError = true)]
|
||||||
private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);
|
private static partial IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);
|
||||||
|
|
||||||
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
[LibraryImport("kernel32.dll", EntryPoint = "GetModuleHandleW", SetLastError = true, StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(System.Runtime.InteropServices.Marshalling.AnsiStringMarshaller))]
|
||||||
private static extern IntPtr GetModuleHandle(string lpModuleName);
|
private static partial IntPtr GetModuleHandle(string lpModuleName);
|
||||||
|
|
||||||
// Delegate for low-level keyboard proc
|
// Delegate for low-level keyboard proc
|
||||||
private delegate IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam);
|
private delegate IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam);
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<UseWPF>true</UseWPF>
|
<UseWPF>true</UseWPF>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
Loading…
Reference in New Issue
Block a user