ption Explicit
Const WM_CAP As Long = &H400
Const WM_CAP_DRIVER_CONNECT As Long = WM_CAP + 10
Const WM_CAP_DRIVER_DISCONNECT As Long = WM_CAP + 11
Const WM_CAP_EDIT_COPY As Long = WM_CAP + 30
Const WS_CHILD As Long = &H40000000
Const WS_VISIBLE As Long = &H10000000
Declare Function SendMessage Lib "User32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As _
Any) As Long
Declare Function DestroyWindow Lib "User32" (ByVal hndw As Long) As Boolean
Declare Function capCreateCaptureWindowA Lib "avicap32.dll" _
(ByVal lpszWindowName As String, ByVal dwStyle As Long, ByVal x As Long, _
ByVal y As Long, ByVal nWidth As Long, _
ByVal nHeight As Integer, ByVal hWndParent As Long, ByVal nID As _
Long) As Long
Declare Function capGetDriverDescriptionA Lib "avicap32.dll" _
(ByVal wDriver As Integer, ByVal lpszName As String, _
ByVal cbName As Long, ByVal lpszVer As String, ByVal cbVer As Long) _
As Boolean
Declare Function GetDesktopWindow Lib "User32" () As Long
Sub WebCamClip()
Dim strName As String
Dim strVer As String
Dim hwnd As Long
Dim iDevice As Long
iDevice = 0
strName = Space(100)
strVer = Space(100)
If capGetDriverDescriptionA(iDevice, strName, 100, strVer, 100) Then
hwnd = capCreateCaptureWindowA(iDevice, WS_CHILD, 0, 0, 640, 480, _
GetDesktopWindow(), 0)
If hwnd Then
SendMessage hwnd, WM_CAP_DRIVER_CONNECT, iDevice, 0
SendMessage hwnd, WM_CAP_EDIT_COPY, 0, 0
SendMessage hwnd, WM_CAP_DRIVER_DISCONNECT, iDevice, 0
DestroyWindow hwnd
End If
End If
End Sub