Private Const WS_CHILD = H40000000
成都創(chuàng)新互聯(lián)公司長期為千余家客戶提供的網(wǎng)站建設(shè)服務(wù),團隊從業(yè)經(jīng)驗10年,關(guān)注不同地域、不同群體,并針對不同對象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺,與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為石樓企業(yè)提供專業(yè)的成都網(wǎng)站建設(shè)、做網(wǎng)站,石樓網(wǎng)站改版等技術(shù)服務(wù)。擁有10年豐富建站經(jīng)驗和眾多成功案例,為您定制開發(fā)。
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
上述代碼就可以實現(xiàn) 但是要注意相應的控件是否存在 不存在的 你自己畫出來
給你個工程自己看...
運行后可以看到自己...
點按鈕保存到c:\1.bmp
1.點擊打開開始菜單 - 電腦設(shè)置,打開電腦設(shè)置窗口。如下圖所示
2.在打開的電腦設(shè)置窗口中,點擊打開“隱私”項進入下一步操作。如下圖所示
3.在隱私功能界面中,找到“攝像頭”點擊打開。如下圖所示
4.點擊將允許應用使用我的攝像頭開啟,關(guān)閉電腦設(shè)置窗口完成操作。如下圖所示