1

I have a USB Camera, MotuhWatch you can see it here

The device has a button on it to capture an Image.

I'm working on a C# WPF application to show and save the captured image.

I'm successful to catch the event when the device connects with the laptop or PC.

But facing in capturing the event when the CAPTURE button the camera is pressed.

I searched a lot and studied many solutions but got no success. The below link help me a lot but I got no success, might be I'm making a mistake.

Solution 1

Solution 2

Solution 3

Here is my code to catch the Event when the USB Camera connects,

public MainWindow()
{
    InitializeComponent();
    ManagementEventWatcher watcher = new ManagementEventWatcher();
    WqlEventQuery query = new WqlEventQuery("SELECT * FROM Win32_DeviceChangeEvent WHERE EventType = 2");
    watcher.EventArrived += new EventArrivedEventHandler(watcher_EventArrived);
    watcher.Query = query;
    watcher.Start();
}
private void watcher_EventArrived(object sender, EventArrivedEventArgs e)
{
    try
    {
        MessageBox.Show("USB Dental Camera Connected Successfully");
    }
    catch (Exception ex)
    {
        MessageBox.Show("Exception Occur: " + ex.Message);
    }
}

I am open to suggestions :)

2
  • The code you have here is generic code for detecting the insertion of any USB device. To monitor events specific to your USB device you will have to get information about the driver used. I would start by contacting the manufacturer. They may have an SDK or at least some general information about the driver for the camera.
    – jweaver
    Dec 26, 2018 at 6:11
  • @jweaver thank you for Your response. Yes I just recognized that this code is generic to capture the CONNECT event of any device. But I'm still working on it and got no success. I also read the documentation of MouthWatch but found nothing important. Dec 26, 2018 at 10:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.