Example #1
0
        bool RegisterForPnpEvents(IntPtr h)
        {
            PInvoke.HidD_GetHidGuid(ref HidGuid);

            DEV_BROADCAST_DEVICEINTERFACE dFilter = new DEV_BROADCAST_DEVICEINTERFACE();

            dFilter.dbcc_size       = Marshal.SizeOf(dFilter);
            dFilter.dbcc_devicetype = gc.DBT_DEVTYP_DEVICEINTERFACE;
            dFilter.dbcc_classguid  = HidGuid;

            hDevNotification = PInvoke.RegisterDeviceNotification(h, dFilter, gc.DEVICE_NOTIFY_WINDOW_HANDLE);
            if (hDevNotification == IntPtr.Zero)
            {
                return(false);
            }

            return(true);
        }
Example #2
0
        bool RegisterForPnpEvents(IntPtr h, Guid DrvGuid)
        {
            DEV_BROADCAST_DEVICEINTERFACE dFilter = new DEV_BROADCAST_DEVICEINTERFACE();

            dFilter.dbcc_size       = Marshal.SizeOf(dFilter);
            dFilter.dbcc_devicetype = CyConst.DBT_DEVTYP_DEVICEINTERFACE;
            dFilter.dbcc_classguid  = DrvGuid;


            IntPtr hNotify = PInvoke.RegisterDeviceNotification(h, dFilter, CyConst.DEVICE_NOTIFY_WINDOW_HANDLE);

            if (hNotify == IntPtr.Zero)
            {
                return(false);
            }

            hDevNotifications.Add(hNotify);

            return(true);
        }
Example #3
0
        internal bool RegisterForPnPEvents(IntPtr hWnd)
        {
            if (_alreadyDisposed)
            {
                throw new ObjectDisposedException("");
            }

            DEV_BROADCAST_HANDLE hFilter = new DEV_BROADCAST_HANDLE();

            hFilter.dbch_size       = Marshal.SizeOf(hFilter);
            hFilter.dbch_devicetype = CyConst.DBT_DEVTYP_HANDLE;
            hFilter.dbch_handle     = _hDevice;

            _hHndNotification = PInvoke.RegisterDeviceNotification(hWnd, hFilter, CyConst.DEVICE_NOTIFY_WINDOW_HANDLE);
            if (_hHndNotification == IntPtr.Zero)
            {
                return(false);
            }

            return(true);
        }