示例#1
0
        protected virtual void OnDeviceRemoved(DEV_BROADCAST_VOLUME volume)
        {
            char c = DriveMaskToLetter(volume.dbcv_unitmask);
            var  e = new RemovableMediaEventArgs()
            {
                Drive = c + ":\\",
            };

            DeviceRemoved?.BeginInvoke(this, e, null, null);
        }
示例#2
0
        protected virtual void OnDeviceArrived(DEV_BROADCAST_VOLUME volume)
        {
            // Get the drive letter
            char c = DriveMaskToLetter(volume.dbcv_unitmask);
            var  e = new RemovableMediaEventArgs {
                Drive = c + ":\\"
            };

            DeviceArrived?.Invoke(this, e);

            // Register for query remove if requested
            if (e.HookQueryRemove)
            {
                // If something is already hooked, unhook it now
                if (this.deviceNotifyHandle != IntPtr.Zero)
                {
                    RegisterForDeviceChange(false, null);
                }

                RegisterQuery(c + ":\\");
            }
        }