public static IntPtr Register(IntPtr hWnd, Guid classGuid, DeviceNotificationFlags flags) { DevBroadcastDeviceInterface dbi = new DevBroadcastDeviceInterface(); dbi.dbcc_size = Marshal.SizeOf <DevBroadcastDeviceInterface>(); dbi.dbcc_devicetype = DeviceType.DeviceInterface; dbi.dbcc_classguid = classGuid; GCHandle gch = GCHandle.Alloc(dbi, GCHandleType.Pinned); IntPtr handle = NativeMethods.RegisterDeviceNotification(hWnd, gch.AddrOfPinnedObject(), flags); gch.Free(); return(handle); }
public static extern IntPtr RegisterDeviceNotification(IntPtr recipient, IntPtr notificationFilter, DeviceNotificationFlags flags);
public static extern IntPtr RegisterDeviceNotificationW( IntPtr hRecipient, ref DevBroadcastDeviceInterfaceW notificationFilter, DeviceNotificationFlags flags );
public static extern IntPtr RegisterDeviceNotification( IntPtr recipient, BroadcastHdr filter, DeviceNotificationFlags flags);
public static extern IntPtr RegisterDeviceNotification(IntPtr recipient, BroadcastHdr filter, DeviceNotificationFlags flags);