這個方法沒問題。
站在用戶的角度思考問題,與客戶深入溝通,找到嵐縣網站設計與嵐縣網站推廣的解決方案,憑借多年的經驗,讓設計與互聯網技術結合,創(chuàng)造個性化、用戶體驗好的作品,建站類型包括:成都網站建設、成都網站設計、企業(yè)官網、英文網站、手機端網站、網站推廣、國際域名空間、網頁空間、企業(yè)郵箱。業(yè)務覆蓋嵐縣地區(qū)。
win8.1,我用網上的方法,有時也有黑屏現象,但多試幾次就好了。有時還會彈出要選擇攝像頭,選擇確認、取消、應用都是黑屏。
Private Const WS_CHILD = H40000000
Private Const WS_VISIBLE = H10000000
Private Const WM_CAP_START = H400
Private Const WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10
Private Const WM_CAP_SET_SCALE = WM_CAP_START + 53
Private Const WM_CAP_SET_PREVIEWRATE = WM_CAP_START + 52
Private Const WM_CAP_SET_PREVIEW = WM_CAP_START + 50
Private 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
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Long) As Long
Private Sub Form_Load()
'建立采集窗口(不顯示窗口,處理后顯示到PIC控件)
uwndc = capCreateCaptureWindowA("", WS_VISIBLE Or WS_CHILD, 0, 0, 320, 240, Me.hWnd, 0)
'連接
SendMessage uwndc, WM_CAP_DRIVER_CONNECT, 0, 0
'Scale開
SendMessage uwndc, WM_CAP_SET_SCALE, True, 0
'顯示刷新MS
SendMessage uwndc, WM_CAP_SET_PREVIEWRATE, 40, 0
'用予覽方式顯示(特殊需要,不顯示予纜)
SendMessage uwndc, WM_CAP_SET_PREVIEW, True, 0
End Sub
上述代碼就可以實現 但是要注意相應的控件是否存在 不存在的 你自己畫出來
給你個工程自己看...
運行后可以看到自己...
點按鈕保存到c:\1.bmp
用directshow獲取幀緩存,轉換為標準圖像格式(比如jpg,png這些),存儲到數據庫的image字段里就行了.