Пример #1
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);
        }
Пример #2
0
 internal static extern IntPtr RegisterDeviceNotification(
     [In] IntPtr h,
     [In] DEV_BROADCAST_HANDLE dFilter,
     [In] uint flags);
Пример #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;
        }