提供对User32.dll的简单封装
using System;
using System.Runtime.InteropServices;
namespace WindowsAPI
{
/// <summary>
/// 提供对User32.dll的简单封装
/// </summary>
public class User32
{
/// <summary>
/// Registers the device or type of device for which a window will receive notifications
/// </summary>
/// <param name="recipient">A handle to the window or service that will receive device events for the devices specified in the NotificationFilter parameter</param>
/// <param name="notificationFilter">A pointer to a block of data that specifies the type of device for which notifications should be sent</param>
/// <param name="flags">A Flags that specify the handle type</param>
/// <returns>If the function succeeds, the return value is a device notification handle</returns>
[DllImport("User32.dll", SetLastError = true)]
public static IntPtr RegisterDeviceNotification(IntPtr recipient, IntPtr notificationFilter, int flags);
/// <summary>
/// Closes the specified device notification handle.
/// </summary>
/// <param name="handle">Device notification handle returned by the RegisterDeviceNotification function</param>
/// <returns></returns>
[DllImport("user32.dll", SetLastError = true)]
public static bool UnregisterDeviceNotification(IntPtr handle);
}
}