2011-06-15 70 views
0

我已經寫了一些代碼,應該顯示從PictureBox中的網絡攝像頭捕獲的視頻。我想以.avi格式錄製和保存顯示的視頻。有沒有辦法做到這一點?從網絡攝像頭保存VB6中的PictureBox中顯示的視頻

我已經嘗試了錄製視頻的代碼是:

Dim hWnd As Long 

hWnd = capCreateCaptureWindow(0, ws_visible Or ws_child, 0, 0, 0, 0, tgt.hWnd, 0) 
Dim a As Boolean 
a = SendMessage(hWnd, wm_cap_driver_connect, 0, 0) 
a = SendMessage(hWnd, WM_CAP_SET_SCALE, True, 0) 
a = SendMessage(hWnd, WM_CAP_DLG_VIDEOCOMPRESSION, 0, 0) 
a = SendMessage(hWnd, WM_CAP_FILE_SET_CAPTURE_FILE, "d:\myvideo1.avi", 0) 
a = SendMessage(hWnd, WM_CAP_SET_SEQUENCE_SETUP, 96, 0) 
a = SendMessage(hWnd, WM_CAP_SEQUENCE, 0, 0) 

但是,它給出了以下行「類型不匹配」錯誤:

a = SendMessage(hWnd, WM_CAP_FILE_SET_CAPTURE_FILE, "d:\myvideo1.avi", 0) 

任何想法?

回答

0

您的API聲明SendMessage與字符串wParam不兼容。你必須讓其他的API聲明可以用字符串中呼籲wParam這樣

Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long 
Public Declare Function SendMessageStr Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As String, lParam As Any) As Long 

然後在違規線使用

a = SendMessageStr(hWnd, WM_CAP_FILE_SET_CAPTURE_FILE, "d:\myvideo1.avi", 0) 

+1

現在我可以保存我的視頻,但是當視頻錄製開始時,我的光標會變得很忙,我不能以這種形式做其他事情。當我點擊該窗體中的任何位置時,視頻停止錄製。有什麼辦法可以解決這個問題嗎? – nightfire001 2011-06-19 18:25:05

1

那麼,事實上,實際的非託管語法要求您指定0參數後的文件名,即您有lParam和wParam的混淆。

相關問題