Describes the device notify event
Inheritance: DeviceNotifyEventArgs
Exemplo n.º 1
0
        private void OnDeviceChange(ref Message m)
        {
            if (!mEnabled)
            {
                return;
            }
            if (m.LParam.ToInt64() != 0)     // ToInt32() only works on non-x64 platforms.
            {
                EventHandler <DeviceNotifyEventArgs> temp = OnDeviceNotify;
                if (!ReferenceEquals(temp, null))
                {
                    DeviceNotifyEventArgs args;
                    DevBroadcastHdr       hdr = new DevBroadcastHdr();
                    Marshal.PtrToStructure(m.LParam, hdr);
                    switch (hdr.DeviceType)
                    {
                    case DeviceType.Port:
                    case DeviceType.Volume:
                    case DeviceType.DeviceInterface:
                        args = new WindowsDeviceNotifyEventArgs(hdr, m.LParam, (EventType)m.WParam.ToInt32());
                        break;

                    default:
                        args = null;
                        break;
                    }
                    if (!ReferenceEquals(args, null))
                    {
                        temp(this, args);
                    }
                }
            }
        }
        private void OnDeviceChange(ref Message m)
        {
            
                if (!mEnabled) return;
                if (m.LParam.ToInt64() != 0) // ToInt32() only works on non-x64 platforms.
                {
                    EventHandler<DeviceNotifyEventArgs> temp = OnDeviceNotify;
                    if (!ReferenceEquals(temp, null))
                    {
                        DeviceNotifyEventArgs args;
                        DevBroadcastHdr hdr = new DevBroadcastHdr();
                        Marshal.PtrToStructure(m.LParam, hdr);
                        switch (hdr.DeviceType)
                        {
                            case DeviceType.Port:
                            case DeviceType.Volume:
                            case DeviceType.DeviceInterface:
                                args = new WindowsDeviceNotifyEventArgs(hdr, m.LParam, (EventType)m.WParam.ToInt32());
                                break;
                            default:
                                args = null;
                                break;
                        }
                        if (!ReferenceEquals(args, null)) temp(this, args);
                    }
                }

        }