winapi - How can I detect if there is a webcam connected to the PC? -
I have a source code to take a picture through the webcam, but I have to know whether the webcam connected to the PC is. If there is no webcam, the program will not call the function to take the photo. If necessary, I have to know that in which case I have to use the API's API.
Languages: Visual Basic 6 using Windows API
The problem with WIA is that not all devices are compatible. But I found a solution of myself: Work together with SendMessage and capCreateCaptureWindowA. If there is no camera, SendMessage returns a "0" code:
mCapHwnd = capCreateCaptureWindowA ("webcaps", 0, 0, 0, m_Width, m_Height, Me.hwnd, 0) DoEvents if SendMessage (mCapHwnd, WM_CAP_CONNECT, 0, 0) & lt; & Gt; 0 Then send a call message (MCA handheld, WMCAPCNATT, 0) Doveentes call send message (MCA handheld, WMCCP_SECPEEfe, 0, 0) LSE MSBBbox "No camera found" and if
I hope It is useful that anyone can find :)
Comments
Post a Comment