RegisterDeviceNotification() private method

private RegisterDeviceNotification ( HANDLE hRecipient, LPVOID NotificationFilter, DeviceNotification Flags ) : HDEVNOTIFY
hRecipient HANDLE
NotificationFilter LPVOID
Flags DeviceNotification
return HDEVNOTIFY
Ejemplo n.º 1
0
        private static unsafe IntPtr RegisterForDeviceNotifications(WinWindowInfo parent)
        {
            BroadcastDeviceInterface type = new BroadcastDeviceInterface();

            type.Size       = BlittableValueType.StrideOf <BroadcastDeviceInterface>(type);
            type.DeviceType = DeviceBroadcastType.INTERFACE;
            type.ClassGuid  = WinRawInput.DeviceInterfaceHid;
            IntPtr num1 = Functions.RegisterDeviceNotification(parent.WindowHandle, new IntPtr((void *)&type), DeviceNotification.WINDOW_HANDLE);
            int    num2 = num1 == IntPtr.Zero ? 1 : 0;

            return(num1);
        }
Ejemplo n.º 2
0
        static IntPtr RegisterForDeviceNotifications(WinWindowInfo parent)
        {
            IntPtr dev_notify_handle;
            BroadcastDeviceInterface bdi = new BroadcastDeviceInterface();

            bdi.Size       = BlittableValueType.StrideOf(bdi);
            bdi.DeviceType = DeviceBroadcastType.INTERFACE;
            bdi.ClassGuid  = DeviceInterfaceHid;
            unsafe
            {
                dev_notify_handle = Functions.RegisterDeviceNotification(parent.WindowHandle,
                                                                         new IntPtr((void *)&bdi), DeviceNotification.WINDOW_HANDLE);
            }
            if (dev_notify_handle == IntPtr.Zero)
            {
                Debug.Print("[Warning] Failed to register for device notifications. Error: {0}", Marshal.GetLastWin32Error());
            }

            return(dev_notify_handle);
        }