干扰监控摄像头的方法 利用Delphi编辑控制摄像头(二)
利用Delphi编辑控制摄像头(二)
完整的程序代码如下unit Unit ; interface uses Windows Messages SysUtils Variants Classes Graphics Controls Forms Dialogs StdCtrls ExtCtrls; type TForm = class(TForm) Panel : TPanel; Button : TButton; Button : TButton; Button : TButton; Button : TButton; Button : TButton; procedure Button Click(Sender: TObject); procedure Button Click(Sender: TObject); procedure Button Click(Sender: TObject); procedure Button Click(Sender: TObject); procedure Button Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); private hWndC : THandle; public { Public declarations } end; var Form : TForm ; const WM_CAP_START = WM_USER; const WM_CAP_STOP = WM_CAP_START + ; const WM_CAP_DRIVER_CONNECT = WM_CAP_START + ; const WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + ; const WM_CAP_SAVEDIB = WM_CAP_START + ; const WM_CAP_GRAB_FRAME = WM_CAP_START + ; const WM_CAP_SEQUENCE = WM_CAP_START + ; const WM_CAP_FILE_SET_CAPTURE_FILEA = WM_CAP_START + ; const WM_CAP_SEQUENCE_NOFILE =WM_CAP_START+ const WM_CAP_SET_OVERLAY =WM_CAP_START+ const WM_CAP_SET_PREVIEW =WM_CAP_START+ const WM_CAP_SET_CALLBACK_VIDEOSTREAM = WM_CAP_START + ; const WM_CAP_SET_CALLBACK_ERROR=WM_CAP_START + ; const WM_CAP_SET_CALLBACK_STATUSA= WM_CAP_START + ; const WM_CAP_SET_CALLBACK_FRAME= WM_CAP_START + ; const WM_CAP_SET_SCALE=WM_CAP_START+ const WM_CAP_SET_PREVIEWRATE=WM_CAP_START+ function capCreateCaptureWindowA(lpszWindowName : PCHAR; dwStyle : longint;x : integer;y : integer;nWidth : integer; nHeight : integer;ParentWin : HWND;nId : integer): HWND; STDCALL EXTERNAL AVICAP DLL ; implementation {$R * dfm} procedure TForm Button Click(Sender: TObject); begin hWndC := capCreateCaptureWindowA( My Own Capture Window WS_CHILD or WS_VISIBLE Panel Left Panel Top Panel Width Panel Height Form Handle ); hWndC := capCreateCaptureWindowA( My Own Capture Window WS_CHILD or WS_VISIBLE Panel Left Panel Top Panel Width Panel Height Form Handle ); if hWndC <> then begin SendMessage(hWndC WM_CAP_SET_CALLBACK_VIDEOSTREAM ); SendMessage(hWndC WM_CAP_SET_CALLBACK_ERROR ); SendMessage(hWndC WM_CAP_SET_CALLBACK_STATUSA ); SendMessage(hWndC WM_CAP_DRIVER_CONNECT ); SendMessage(hWndC WM_CAP_SET_SCALE ); SendMessage(hWndC WM_CAP_SET_PREVIEWRATE ); SendMessage(hWndC WM_CAP_SET_OVERLAY ); SendMessage(hWndC WM_CAP_SET_PREVIEW ); end; end; procedure TForm Button Click(Sender: TObject); begin if hWndC <> then begin SendMessage(hWndC WM_CAP_DRIVER_DISCONNECT ); hWndC := ; end; end; procedure TForm Button Click(Sender: TObject); begin if hWndC <> then begin SendMessage(hWndC WM_CAP_SAVEDIB longint(pchar( c:test bmp ))); end; end; procedure TForm Button Click(Sender: TObject); begin if hWndC <> then begin SendMessage(hWndC WM_CAP_FILE_SET_CAPTURE_FILEA Longint(pchar( c:test avi ))); SendMessage(hWndC WM_CAP_SEQUENCE ); end; end; procedure TForm Button Click(Sender: TObject); begin if hWndC <> then begin SendMessage(hWndC WM_CAP_STOP ); end; end; procedure TForm FormClose(Sender: TObject; var Action: TCloseAction); begin if hWndC <> then begin SendMessage(hWndC WM_CAP_DRIVER_DISCONNECT ); end; end; end
如果电脑没有摄像头 但又想看看程序的效果 可以么?
当然可以 找个虚拟摄像头不就搞定 大家可以试试SoftCam这个软件 它是一个名副其实的软件摄像机 能模拟成为 真实的 摄像机 提醒一下各位 大家可不要用这个东东用在QQ MSN等聊天软件上欺骗MM或GG啊

关于摄像头编程 大家也可以看看这组VCL组件 DSPack DSPack是一套使用微软Direct Show和DirectX技术的类和组件 设计工作于DirectX 支持系统Win X ME 和Windows XP
lishixinzhi/Article/program/Delphi/201311/24709