資源簡介
C#調(diào)用攝像頭拍照錄像保存 簡單 易懂 方便 可運行

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
using?System.Runtime.InteropServices;
using?System.Drawing.Imaging;
namespace?調(diào)用攝像頭
{
????public?partial?class?CameraForm?:?Form
????{
????????private?int?hHwnd;
????????private?const?int?port?=?2000;
????????public?CameraForm()
????????{
????????????InitializeComponent();
????????}
????????public?struct?videohdr_tag
????????{
????????????public?byte[]?lpData;
????????????public?int?dwBufferLength;
????????????public?int?dwBytesUsed;
????????????public?int?dwTimeCaptured;
????????????public?int?dwUser;
????????????public?int?dwFlags;
????????????public?int[]?dwReserved;
????????}
????????public?delegate?bool?CallBack(int?hwnd?int?lParam);
????????///??????
????????///???必需的設計器變量。???
????????///??? ???
????????//private?System.ComponentModel.Container?components?=?null;
????????[DllImport(“avicap32.dll“?CharSet?=?CharSet.Ansi?SetLastError?=?true?ExactSpelling?=?true)]
????????public?static?extern?int?capCreateCaptureWindowA([MarshalAs(UnmanagedType.VBByRefStr)]???ref???string?lpszWindowName?int?dwstyle?int?x?int?y?int?nWidth?short?nHeight?int?hWndParent?int?nID);
????????[DllImport(“avicap32.dll“?CharSet?=?CharSet.Ansi?SetLastError?=?true?ExactSpelling?=?true)]
????????public?static?extern?bool?capGetDriverDescriptionA(short?wDriver?[MarshalAs(UnmanagedType.VBByRefStr)]???ref???string?lpszName?int?cbName?[MarshalAs(UnmanagedType.VBByRefStr)]???ref???string?lpszVer?int?cbVer);
????????[DllImport(“user32“?CharSet?=?CharSet.Ansi?SetLastError?=?true?ExactSpelling?=?true)]
????????public?static?extern?bool?DestroyWindow(int?hndw);
????????[DllImport(“user32“?EntryPoint?=?“SendMessageA“?CharSet?=?CharSet.Ansi?SetLastError?=?true?ExactSpelling?=?true)]
????????public?static?extern?int?SendMessage(int?hwnd?int?wMsg?int?wParam?[MarshalAs(UnmanagedType.AsAny)]???object?lParam);
????????[DllImport(“user32“?CharSet?=?CharSet.Ansi?SetLastError?=?true?ExactSpelling?=?true)]
????????public?static?extern?int?SetWindowPos(int?hwnd?int?hWndInsertAfter?int?x?int?y?int?cx?int?cy?int?wFlags);
????????[DllImport(“vfw32.dll“)]
????????public?static?extern?string?capVideoStreamCallback(int?hwnd?videohdr_tag?videohdr_tag);
????????[DllImport(“vicap32.dll“?CharSet?=?CharSet.Ansi?SetLastError?=?true?ExactSpelling?=?true)]
????????public?static?extern?bool?capSetCallbackOnframe(int?hwnd?string?s);
????????private?void?OpenCapture()
????????{
????????????int?intWidth?=?this.panel1.Width;
????????????int?intHeight?=?this.panel1.Height;
????????????int?intDevice?=?0;
????????????string?refDevice?=?intDevice.ToString();
????????????//創(chuàng)建視頻窗口并得到句柄
????????????hHwnd?=?CameraForm.capCreateCaptureWindowA(ref???refDevice?1342177280?0?0?1024?800?this.panel1.Handle.ToInt32()?0);
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????11776??2011-11-28?08:15??調(diào)用攝像頭\調(diào)用攝像頭\bin\Debug\調(diào)用攝像頭.exe
?????文件??????26112??2011-11-28?08:15??調(diào)用攝像頭\調(diào)用攝像頭\bin\Debug\調(diào)用攝像頭.pdb
?????文件??????14328??2011-11-28?08:15??調(diào)用攝像頭\調(diào)用攝像頭\bin\Debug\調(diào)用攝像頭.vshost.exe
?????文件???????5026??2011-11-28?08:15??調(diào)用攝像頭\調(diào)用攝像頭\CameraForm.cs
?????文件???????4593??2011-11-28?08:15??調(diào)用攝像頭\調(diào)用攝像頭\CameraForm.Designer.cs
?????文件???????5814??2011-11-28?08:15??調(diào)用攝像頭\調(diào)用攝像頭\CameraForm.resx
?????文件????????180??2011-11-28?08:15??調(diào)用攝像頭\調(diào)用攝像頭\obj\Debug\調(diào)用攝像頭.CameraForm.resources
?????文件????????865??2011-11-28?08:15??調(diào)用攝像頭\調(diào)用攝像頭\obj\Debug\調(diào)用攝像頭.csproj.FileListAbsolute.txt
?????文件????????852??2011-11-28?08:15??調(diào)用攝像頭\調(diào)用攝像頭\obj\Debug\調(diào)用攝像頭.csproj.GenerateResource.Cache
?????文件??????11776??2011-11-28?08:15??調(diào)用攝像頭\調(diào)用攝像頭\obj\Debug\調(diào)用攝像頭.exe
?????文件??????26112??2011-11-28?08:15??調(diào)用攝像頭\調(diào)用攝像頭\obj\Debug\調(diào)用攝像頭.pdb
?????文件????????180??2011-11-28?08:14??調(diào)用攝像頭\調(diào)用攝像頭\obj\Debug\調(diào)用攝像頭.Properties.Resources.resources
?????文件????????501??2011-11-28?08:11??調(diào)用攝像頭\調(diào)用攝像頭\Program.cs
?????文件???????1362??2011-11-28?07:49??調(diào)用攝像頭\調(diào)用攝像頭\Properties\AssemblyInfo.cs
?????文件???????2880??2011-11-28?07:49??調(diào)用攝像頭\調(diào)用攝像頭\Properties\Resources.Designer.cs
?????文件???????5612??2011-11-28?07:49??調(diào)用攝像頭\調(diào)用攝像頭\Properties\Resources.resx
?????文件???????1100??2011-11-28?07:49??調(diào)用攝像頭\調(diào)用攝像頭\Properties\Settings.Designer.cs
?????文件????????249??2011-11-28?07:49??調(diào)用攝像頭\調(diào)用攝像頭\Properties\Settings.settings
?????文件???????3766??2011-11-28?08:14??調(diào)用攝像頭\調(diào)用攝像頭\調(diào)用攝像頭.csproj
?????文件????????935??2011-11-28?07:49??調(diào)用攝像頭\調(diào)用攝像頭.sln
????..A..H.?????13824??2011-11-28?08:15??調(diào)用攝像頭\調(diào)用攝像頭.suo
?????目錄??????????0??2011-11-28?08:08??調(diào)用攝像頭\調(diào)用攝像頭\obj\Debug\Refactor
?????目錄??????????0??2011-11-28?07:49??調(diào)用攝像頭\調(diào)用攝像頭\obj\Debug\TempPE
?????目錄??????????0??2011-11-28?08:14??調(diào)用攝像頭\調(diào)用攝像頭\bin\Debug
?????目錄??????????0??2011-11-28?08:15??調(diào)用攝像頭\調(diào)用攝像頭\obj\Debug
?????目錄??????????0??2011-11-28?08:08??調(diào)用攝像頭\調(diào)用攝像頭\bin
?????目錄??????????0??2011-11-28?07:49??調(diào)用攝像頭\調(diào)用攝像頭\obj
?????目錄??????????0??2011-11-28?07:49??調(diào)用攝像頭\調(diào)用攝像頭\Properties
?????目錄??????????0??2011-11-28?08:15??調(diào)用攝像頭\調(diào)用攝像頭
?????目錄??????????0??2011-11-28?07:49??調(diào)用攝像頭
............此處省略3個文件信息
評論
共有 條評論