tags:

views:

212

answers:

2

I have the source code for taking a picture via webcam, but I need to know if there's a webcam connected to the PC. If there's no webcam, the program won't call the function for taking photos. If necessary, I need to know which window's Api I have to use in this case.

Language: Visual Basic 6 using windows Apis.

+1  A: 

I think there's a flash app for that, if you're working on a website. Otherwise you might want to look into the Windows Image Acquisition API.

Jeff
Nope, it is a desktop app. I've seen the code for flash, but I need it for VB6. Not the entire algorithm, just the Api that can detect the webcam.
yelinna
Take a look at the WIA api, then.
Jeff
A: 

The problem with the WIA is that not all devices are compatible. But I found the solution myself: SendMessage and capCreateCaptureWindowA work together. If there's no camera, SendMessage returns a "0". This is the code:

mCapHwnd = capCreateCaptureWindowA("WebCap", 0, 0, 0, m_Width, m_Height, Me.hwnd, 0)
DoEvents
If SendMessage(mCapHwnd, WM_CAP_CONNECT, 0, 0) <> 0 Then
Call SendMessage(mCapHwnd, WM_CAP_CONNECT, 0, 0)
DoEvents
Call SendMessage(mCapHwnd, WM_CAP_SET_PREVIEW, 0, 0)
Else
MsgBox "No Camera Detected"
End If

I hope somebody can find this useful :)

yelinna