问题
How can I programmatically detect whether a webcam device is plugged in to the PC or not, return 'True' or 'False.
回答1:
Might be some better way of doing this but the only one I can think of would be to use GetRawInputDeviceList
to enumerate all USB devices and then using GetRawInputDeviceInfo
to get out more information about them.
Webcams should show up as HID, but I don't know if there's any way to tell for sure if it's a webcam.
See here for a C# sample (could probably use a C# to VB.Net converter if you're not comfortable with C#).
来源:https://stackoverflow.com/questions/2946180/vb-net-detect-webcam