In my new product I'd like to be able to detect if there is a Pico Scope attached before calling ps2000_open_unit().
The reason is that I wish the make the UI as slick and user friendly as possible, so I don't want to do user-nagging such as "Please attach your scope and hit 'connect'", and I can't just keep polling open_unit because it repeatedly displays the PicoScope spash screen.
So, therefore I'd like to detect if a scope is present before I call open_unit() - is there a good way to do this?
This cannot be done using our driver, but it is possible using the Windows API or .net.
I don't know exactly how it's done, but my understanding is that Windows broadcasts a message whenever a USB device is connected. You would then need to read the device descriptor to determine whether it is the device you are looking for.
For the benefit of the list lurkers...
This turned out to be quite straightforward.
The Windows API call you need is : RegisterDeviceNotification(...)
With this you register for device notifications, and then you add a message handler to your program which gets called when a WM_DEVICECHANGE arrives.
In your message handler, you check the wParam of the message for DBT_DEVICEREMOVECOMPLETE or DBT_DEVICEARRIVAL, if you have one of these then the lParam points to a struct containing more information.
You then check the device name member of the structure pointed to by the lParam to see if it contain the picotech vendor ID (which is 0x0ce9).
So now you know whether a PicoScope has been attached or removed and you can take the appropriate action.