偶寫C#

一段代碼~視頻捕捉

using System;

using System.Text;

using System.Windows.Forms;

using System.Drawing;

using System.Runtime.InteropServices;

namespace VideoCap

{

/// <summary>

/// API 的摘要說明。

/// </summary>

public class API

{

public const int WS_BORDER = 0x800000;

public const int WS_CAPTION = 0xC00000;

public const int WS_SYSMENU = 0x80000;

public const int WS_CHILD = 0x40000000;

public const int WS_VISIBLE = 0x10000000;

public const int WS_OVERLAPPED = 0x0;

public const int WS_MINIMIZEBOX = 0x20000;

public const int WS_MAXIMIZEBOX = 0x10000;

public const int WS_THICKFRAME = 0x40000;

//public const int WS_OVERLAPPEDWINDOW = (WS_OVERLAPPED Or WS_CAPTION Or WS_SYSMENU Or WS_THICKFRAME Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX);

public const int SWP_NOMOVE = 0x2;

public const int SWP_NOSIZE = 1;

public const int SWP_NOZORDER = 0x4;

public const int HWND_BOTTOM = 1;

public const int HWND_TOPMOST = -1;

public const int HWND_NOTOPMOST = -2;

public const int SM_CYCAPTION = 4;

public const int SM_CXFRAME = 32;

public const int SM_CYFRAME = 33;

public const int WS_EX_TRANSPARENT = 0x20;

public const int GWL_STYLE = (-16);

public const int WM_USER = 0x400;

public const int WM_CAP_START = WM_USER;

public const int WM_CAP_GET_CAPSTREAMPTR = WM_CAP_START + 1;

public const int WM_CAP_SET_CALLBACK_ERROR = WM_CAP_START + 2;

public const int WM_CAP_SET_CALLBACK_STATUS = WM_CAP_START + 3;

public const int WM_CAP_SET_CALLBACK_YIELD = WM_CAP_START + 4;

public const int WM_CAP_SET_CALLBACK_FRAME = WM_CAP_START + 5;

public const int WM_CAP_SET_CALLBACK_VIDEOSTREAM = WM_CAP_START + 6;

public const int WM_CAP_SET_CALLBACK_WAVESTREAM = WM_CAP_START + 7;

public const int WM_CAP_GET_USER_DATA = WM_CAP_START + 8;

public const int WM_CAP_SET_USER_DATA = WM_CAP_START + 9;

public const int WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10;

public const int WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11;

public const int WM_CAP_DRIVER_GET_NAME = WM_CAP_START + 12;

public const int WM_CAP_DRIVER_GET_VERSION = WM_CAP_START + 13;

public const int WM_CAP_DRIVER_GET_CAPS = WM_CAP_START + 14;

public const int WM_CAP_FILE_SET_CAPTURE_FILE = WM_CAP_START + 20;

public const int WM_CAP_FILE_GET_CAPTURE_FILE = WM_CAP_START + 21;

public const int WM_CAP_FILE_ALLOCATE = WM_CAP_START + 22;

public const int WM_CAP_FILE_SAVEAS = WM_CAP_START + 23;

public const int WM_CAP_FILE_SET_INFOCHUNK = WM_CAP_START + 24;

public const int WM_CAP_FILE_SAVEDIB = WM_CAP_START + 25;

public const int WM_CAP_EDIT_COPY = WM_CAP_START + 30;

public const int WM_CAP_SET_AUDIOFORMAT = WM_CAP_START + 35;

public const int WM_CAP_GET_AUDIOFORMAT = WM_CAP_START + 36;

public const int WM_CAP_DLG_VIDEOFORMAT = WM_CAP_START + 41;

public const int WM_CAP_DLG_VIDEOSOURCE = WM_CAP_START + 42;

public const int WM_CAP_DLG_VIDEODISPLAY = WM_CAP_START + 43;

public const int WM_CAP_GET_VIDEOFORMAT = WM_CAP_START + 44;

public const int WM_CAP_SET_VIDEOFORMAT = WM_CAP_START + 45;

public const int WM_CAP_DLG_VIDEOCOMPRESSION = WM_CAP_START + 46;

public const int WM_CAP_SET_PREVIEW = WM_CAP_START + 50;

public const int WM_CAP_SET_OVERLAY = WM_CAP_START + 51;

public const int WM_CAP_SET_PREVIEWRATE = WM_CAP_START + 52;

public const int WM_CAP_SET_SCALE = WM_CAP_START + 53;

public const int WM_CAP_GET_STATUS = WM_CAP_START + 54;

public const int WM_CAP_SET_SCROLL = WM_CAP_START + 55;

public const int WM_CAP_GRAB_FRAME = WM_CAP_START + 60;

public const int WM_CAP_GRAB_FRAME_NOSTOP = WM_CAP_START + 61;

public const int WM_CAP_SEQUENCE = WM_CAP_START + 62;

public const int WM_CAP_SEQUENCE_NOFILE = WM_CAP_START + 63;

public const int WM_CAP_SET_SEQUENCE_SETUP = WM_CAP_START + 64;

public const int WM_CAP_GET_SEQUENCE_SETUP = WM_CAP_START + 65;

public const int WM_CAP_SET_MCI_DEVICE = WM_CAP_START + 66;

public const int WM_CAP_GET_MCI_DEVICE = WM_CAP_START + 67;

public const int WM_CAP_STOP = WM_CAP_START + 68;

public const int WM_CAP_ABORT = WM_CAP_START + 69;

public const int WM_CAP_SINGLE_FRAME_OPEN = WM_CAP_START + 70;

public const int WM_CAP_SINGLE_FRAME_CLOSE = WM_CAP_START + 71;

public const int WM_CAP_SINGLE_FRAME = WM_CAP_START + 72;

public const int WM_CAP_PAL_OPEN = WM_CAP_START + 80;

public const int WM_CAP_PAL_SAVE = WM_CAP_START + 81;

public const int WM_CAP_PAL_PASTE = WM_CAP_START + 82;

public const int WM_CAP_PAL_AUTOCREATE = WM_CAP_START + 83;

public const int WM_CAP_PAL_MANUALCREATE = WM_CAP_START + 84;

// Following added post VFW 1.1

public const int WM_CAP_SET_CALLBACK_CAPCONTROL = WM_CAP_START + 85;

// Defines end of the message range

public const int WM_CAP_END = WM_CAP_SET_CALLBACK_CAPCONTROL;

public API()

{

//

// TODO: 在此處添加構造函數邏輯

//

}

private const string avicap = "avicap32.dll";

// WaveOut calls

[DllImport(avicap)]

public static extern int capCreateCaptureWindow(string lpszWindowName,int dwStyle,int x,int y,int nWidth,int nHeight,IntPtr hWndParent, int nID);

[DllImport(avicap)]

public static extern bool capGetDriverDescription(int wDriver,StringBuilder lpszName ,int cbName,StringBuilder lpszVer,int cbVer);

[DllImport("User32.dll",EntryPoint="SendMessage")]

public static extern int SendMessage(

int hWnd, // handle to destination window

int Msg, // message

int wParam, // first message parameter

int lParam // second message

);

[DllImport("User32.dll",EntryPoint="SendMessage")]

public static extern int SendMessageS(

int hWnd, // handle to destination window

int Msg, // message

int wParam, // first message parameter

string lParam // second message

);

[DllImport("User32.dll",EntryPoint="SendMessage")]

public static extern int SendMessagePtr(

int hWnd, // handle to destination window

int Msg, // message

int wParam, // first message parameter

out CAPDRIVERCAPS lParam // second message

);

//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

//Declare Function capGetDriverDescriptionA Lib "avicap32.dll" ( ByVal wDriver As Integer, ByVal lpszName As String,

//ByVal cbName As Long, ByVal lpszVer As String, ByVal cbVer As Long) As Boolean

}

public struct CAPDRIVERCAPS

{

public int wDeviceIndex ; // Driver index in system.ini

public int fHasOverlay ; // Can device overlay?

public int fHasDlgVideoSource ; // Has Video source dlg?

public int fHasDlgVideoFormat ; // Has Format dlg?

public int fHasDlgVideoDisplay ; // Has External out dlg?

public int fCaptureInitialized ; // Driver ready to capture?

public int fDriverSuppliesPalettes ; // Can driver make palettes?

public int hVideoIn ; // Driver In channel

public int hVideoOut ; // Driver Out channel

public int hVideoExtIn ; // Driver Ext In channel

public int hVideoExtOut ; // Driver Ext Out channel

}

}

 
如何使用c#操作ACCESS數據庫-其他軟件
手頭沒有Microsoft Access,如何建立數據庫,一切依然簡單. 首先引用C:\Program Files\Common Files\System\ado\msadox.dll,該DLL包含ADOX命名空間; 接著引用C:\Program Files\Common Files\System\ado\msjro.dll,該DL...查看完整版>>如何使用c#操作ACCESS數據庫-其他軟件
 
C#利用SMTP服務器發送郵件-其他軟件
在命名空間using System.Net.Mail中提供方法根據指定的smtp服務器來發送郵件。下面說說如何實現: 1、首先要發送郵件,需要有一個郵箱帳號,比如網易郵箱、新郎郵箱、qq郵箱等,我以網易的163郵箱爲例。然後我們需...查看完整版>>C#利用SMTP服務器發送郵件-其他軟件
 
在C++中實現C#的delegate機制-C/C++
  由于這段時間較忙,自從上次我發布了一個供初學者學習的“MFC”程序後,就沒怎麽寫文章了。這段時間在忙新的項目,項目邏輯還算複雜,用了好多有閃光點的技術,下面我要討論的是閃光點之一:在C++中實現C#的dele...查看完整版>>在C++中實現C#的delegate機制-C/C++
 
[C#.Net]解讀C#中的規則表達式-編程語言
  多少年來,許多的編程語言和工具都包含對規則表達式的支持,.NET基礎類庫中包含有一個名字空間和一系列可以充分發揮規則表達式威力的類,而且它們也都與未來的Perl 5中的規則表達式兼容。  此外,regexp類還能...查看完整版>>[C#.Net]解讀C#中的規則表達式-編程語言
 
[C#.Net]調用kernel32讀寫ini文件-編程語言
  具體實現的代碼如下:  using System;  using System.Drawing;  using System.Collections;  using System.ComponentModel;  using System.Windows.Forms;  using System.Data;  using System.Run...查看完整版>>[C#.Net]調用kernel32讀寫ini文件-編程語言
 
· 臨近國慶,李小璐與女兒在天安門前合影

http://image.wangchao.net.cn/users/...

· 震驚!原來酒駕處罰這麽嚴重

酒駕處罰標准 不要有任何一絲僥幸心理! http://image....

· 把年齡相仿的獅虎熊放一起,誰更厲害?結果出人意料

很多人都想知道獅子、老虎和熊打起來誰最厲害,于是便有好事之人把這三種動物關在一起...