step0:讀取webcam列表
capGetDriverDescriptionA 只能不知道為啥讀到一個 參考其他如下文
放棄用capGetDriverDescriptionA了
參考某人:
改成用WM_CAP_DLG_VIDEOSOURCE
不過還是很想知道capGetDriverDescriptionA為什麼抓不到裝置= =
jk:雖然列表列不出來 不過還是可以透過使用"選擇來源"來選第二隻webcam
'step1:要先連接視訊驅動
'step2:觸發選擇目前視訊來源視窗
以下引自
http://www.blueshop.com.tw/board/show.asp?subcde=BRD2007072614550011F&fumcde=FUM20050124191756KKC
Public Class Form1
2
3 Private Declare Function capCreateCaptureWindow Lib "avicap32.dll" Alias "capCreateCaptureWindowA" _
4 (ByVal lpszWindowName As String, ByVal dwStyle As Integer, _
5 ByVal x As Integer, ByVal y As Integer, _
6 ByVal nWidth As Integer, ByVal nHeight As Integer, _
7 ByVal hwndParent As Integer, ByVal nID As Integer) As Integer
8
9 Private Declare Function capGetDriverDescription Lib "avicap32.dll" Alias "capGetDriverDescriptionA" _
10 (ByVal dwDriverIndex As Integer, ByVal lpszName As String, _
11 ByVal cbName As Integer, ByVal lpszVer As String, ByVal cbVer As Integer) As Boolean
12
13 Private Declare Function SendMessageAsLong Lib "user32" Alias "SendMessageA" _
14 (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
15
16 Private hWnd As Integer = 0
17 Private WithEvents tmr As Timer
18
'step1:要先連接視訊驅動
19 Private Sub Form1_Load(ByVal s As Object, ByVal e As EventArgs) Handles MyBase.Load
20 hWnd = capCreateCaptureWindow("PH Capture", &H40000000 Or &H10000000, 0, 0, 320, 240, PictureBox1.Handle, 0)
21 SendMessageAsLong(hWnd, 1034, 0, 0)
22 SendMessageAsLong(hWnd, 1038, 44, 0)
23 SendMessageAsLong(hWnd, 1974, 1, 0)
24 SendMessageAsLong(hWnd, 1976, 66, 0)
25 Application.DoEvents()
26 tmr = New Timer
27 tmr.Interval = 100
28 tmr.Start()
29 End Sub
30
31 Private Sub tmr_Tick(ByVal s As Object, ByVal e As EventArgs) Handles tmr.Tick
32 SendMessageAsLong(hWnd, 1084, 0, 0)
33 SendMessageAsLong(hWnd, 1054, 0, 0)
34 End Sub
35
'step2:觸發選擇目前視訊來源視窗
36 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
37 SendMessageAsLong(hWnd, 1066, 0, 0) ' 視訊來源 找選擇哪隻webcam
38 End Sub
39
40 Private Sub Form1_FormClosed(ByVal s As Object, ByVal e As FormClosedEventArgs) Handles Me.FormClosed
41 tmr.Stop()
42 SendMessageAsLong(hWnd, 1035, 0, 0)
43 End Sub
44
45 End Class
- Apr 27 Wed 2011 04:33
vb2008~抓取第二隻webcam
close
全站熱搜
留言列表
禁止留言