Esempio n. 1
0
        private void OnDeviceChange(IntPtr reason, IntPtr pHdr)
        {
            // Check for the right category of event
            if (m_rdn.CheckEventDetails(reason, pHdr))
            {
                UpdateDeviceList();
                UpdateUI();

                // If we are capturing, check and see if the device was the one we were using.  We do this
                // by comparing the symbolic name of the capture device to the symbolic name of the changed
                // device.
                if (m_pCapture != null && m_pCapture.IsCapturing())
                {
                    bool    bDeviceLost = false;
                    string  sSym        = RegisterDeviceNotifications.ParseDeviceSymbolicName(pHdr);
                    HResult hr          = m_pCapture.CheckDeviceLost(sSym, out bDeviceLost);

                    if (hr < 0 || bDeviceLost)
                    {
                        StopCapture();

                        MessageBox.Show(this, "The capture device was removed or lost.", "Lost Device", MessageBoxButtons.OK);
                    }
                }
            }
        }