1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
Private Structure POINTAPI
Dim x As Integer
Dim y As Integer
End Structure
Private Structure CAPSTATUS
Dim uiImageWidth As UInt32 ' Width of the image
Dim uiImageHeight As UInt32 ' Height of the image
Dim fLiveWindow As Boolean ' Now Previewing video?
Dim fOverlayWindow As Boolean ' Now Overlaying video?
Dim fScale As Boolean ' Scale image to client?
Dim ptScroll As POINTAPI ' Scroll position
Dim fUsingDefaultPalette As Boolean ' Using default driver palette?
Dim fAudioHardware As Boolean ' Audio hardware present?
Dim fCapFileExists As Boolean ' Does capture file exist?
Dim dwCurrentVideoFrame As Integer ' # of video frames cap'td
Dim dwCurrentVideoFramesDropped As Integer ' # of video frames dropped
Dim dwCurrentWaveSamples As Integer ' # of wave samples cap'td
Dim dwCurrentTimeElapsedMS As Integer ' Elapsed capture duration
Dim hPalCurrent As Integer ' Current palette in use
Dim fCapturingNow As Boolean ' Capture in progress?
Dim dwReturn As Integer ' Error value after any operation
Dim wNumVideoAllocated As UInt32 ' Actual number of video buffers
Dim wNumAudioAllocated As UInt32 ' Actual number of audio buffers
End Structure
Private Declare Function capGetStatus Lib "avicap32.dll" (ByVal hwnd As Int32, _
ByRef status As CAPSTATUS, _
ByVal wSize As Int32)
' Open Preview window
_hwnd = capCreateCaptureWindowA(_iDevice, WS_VISIBLE Or WS_CHILD, 0, 0, 1280, _
700, window.Handle.ToInt32, 0)
' Connect to device
If SendMessage(_hwnd, WM_CAP_DRIVER_CONNECT, _iDevice, 0) <> 1 Then
' Error connecting to device, close window
DestroyWindow(_hwnd)
Throw New Exception("Can't connect to device.")
End If
'Get infos
'SendMessage(_hwnd, WM_CAP_GET_STATUS, Marshal.SizeOf(_lCapStatus), _lCapStatus)
Dim status As New CAPSTATUS
Try
capGetStatus(_hwnd, status, Marshal.SizeOf(status))
Catch ex As Exception
Throw ex
End Try |
Partager