我用的是VB Dim FileName As String Dim retVal As Boolean FileName = "c:\001.bmp" capFileSaveDIB(lwndC, FileName)其他代码: Function capFileSaveDIB(ByVal hCapWnd As Long, ByVal FilePath As String) As Boolean capFileSaveDIB = SendMessageS(hCapWnd, WM_CAP_FILE_SAVEDIB, 0&, FilePath) End FunctionDeclare Function SendMessageS Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As String) As Long
DirectShowgoogle 采集等 许多现成的代码
RECT rect;
GetDlgItem(nId)->GetWindowRect(&rect);
ScreenToClient(&rect);
// TODO: Add extra initialization here
hWndC = capCreateCaptureWindow (NULL,WS_CHILD | WS_VISIBLE,
rect.left, rect.top, rect.right-rect.left , rect.bottom- rect.top,
this->m_hWnd/*GetDlgItem(nId)->m_hWnd*/, 1);
if(hWndC==NULL)
{
ZcMessage.DoModal("视频窗口初始化失败");
return TRUE; // return TRUE unless you set the focus to a control
}
LRESULT res = ::SendMessage(hWndC, WM_CAP_DRIVER_CONNECT, 0, 0L);
if(res==0)
{
capDriverDisconnect (hWndC);
::ShowWindow(hWndC,SW_HIDE);
hWndC = NULL;
ZcMessage.DoModal("视频窗口初始化失败");
return FALSE;
}
capPreviewRate(hWndC, 66); // rate, in milliseconds
capPreview(hWndC, TRUE); // starts preview
capPreviewScale(hWndC,TRUE);//
capSetCallbackOnFrame(hWndC,fpFrameCallback);////////////////////
capFileSaveDIB(hWndC, mOutFileName.GetBuffer(0));
Dim FileName As String
Dim retVal As Boolean
FileName = "c:\001.bmp"
capFileSaveDIB(lwndC, FileName)其他代码:
Function capFileSaveDIB(ByVal hCapWnd As Long, ByVal FilePath As String) As Boolean
capFileSaveDIB = SendMessageS(hCapWnd, WM_CAP_FILE_SAVEDIB, 0&, FilePath)
End FunctionDeclare Function SendMessageS Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As String) As Long
这个是完整的
http://blog.csdn.net/beautifulmouse/archive/2008/05/27/2486254.aspx