給你個(gè)工程自己看...
成都創(chuàng)新互聯(lián)公司致力于互聯(lián)網(wǎng)品牌建設(shè)與網(wǎng)絡(luò)營(yíng)銷(xiāo),包括網(wǎng)站制作、成都網(wǎng)站設(shè)計(jì)、SEO優(yōu)化、網(wǎng)絡(luò)推廣、整站優(yōu)化營(yíng)銷(xiāo)策劃推廣、電子商務(wù)、移動(dòng)互聯(lián)網(wǎng)營(yíng)銷(xiāo)等。成都創(chuàng)新互聯(lián)公司為不同類型的客戶提供良好的互聯(lián)網(wǎng)應(yīng)用定制及解決方案,成都創(chuàng)新互聯(lián)公司核心團(tuán)隊(duì)10年專注互聯(lián)網(wǎng)開(kāi)發(fā),積累了豐富的網(wǎng)站經(jīng)驗(yàn),為廣大企業(yè)客戶提供一站式企業(yè)網(wǎng)站建設(shè)服務(wù),在網(wǎng)站建設(shè)行業(yè)內(nèi)樹(shù)立了良好口碑。
運(yùn)行后可以看到自己...
點(diǎn)按鈕保存到c:\1.bmp
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開(kāi)
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
上述代碼就可以實(shí)現(xiàn) 但是要注意相應(yīng)的控件是否存在 不存在的 你自己畫(huà)出來(lái)
這個(gè)方法沒(méi)問(wèn)題。
win8.1,我用網(wǎng)上的方法,有時(shí)也有黑屏現(xiàn)象,但多試幾次就好了。有時(shí)還會(huì)彈出要選擇攝像頭,選擇確認(rèn)、取消、應(yīng)用都是黑屏。