请将以下vb代码如何写为C#代码 谢谢Dim lpszName As New VBFixedStringAttribute(100)
Dim i As Integer
Dim DriverName As String = Space(80)
Dim DriverVersion As String = Space(80)Dim bmp As BITMAPINFOWith bmp.bmiHeader
.biSize = Len(bmp.bmiHeader)
.biWidth = 320
.biHeight = 240
.biPlanes = 1
.biBitCount = 24
End Withi=0 '摄像头所在的组号
capGetDriverDescriptionA(i, DriverName, 80, DriverVersion, 80)lwndC1 = capCreateCaptureWindowA(DriverName, WS_VISIBLE Or WS_CHILD, 0, 0, PictureBox1.Width, PictureBox1.Height, PictureBox1.Handle.ToInt32, 0)If capDriverConnect(lwndC1, 0) Then
capDlgVideoSource(lwndC1)
capPreviewRate(lwndC1, 66)
capPreview(lwndC1, True)
capSetVideoFormat(lwndC1, bmp, Len(bmp))
SetWindowPos(lwndC1, 0, 0, 0, bmp.bmiHeader.biWidth, bmp.bmiHeader.biHeight, SWP_NOMOVE Or SWP_NOZORDER)
ListBox1.Items.Add(DriverName.Trim)End IfFunction capDlgVideoSource(ByVal lwnd As Long) As Boolean
capDlgVideoSource = SendMessage(lwnd, WM_CAP_DLG_VIDEOSOURCE, 0, 0)
End Function其中:
Public Const WM_CAP_START As Integer = WM_USER
Public Const WM_CAP_DLG_VIDEOSOURCE As Integer = WM_CAP_START + 42
Dim i As Integer
Dim DriverName As String = Space(80)
Dim DriverVersion As String = Space(80)Dim bmp As BITMAPINFOWith bmp.bmiHeader
.biSize = Len(bmp.bmiHeader)
.biWidth = 320
.biHeight = 240
.biPlanes = 1
.biBitCount = 24
End Withi=0 '摄像头所在的组号
capGetDriverDescriptionA(i, DriverName, 80, DriverVersion, 80)lwndC1 = capCreateCaptureWindowA(DriverName, WS_VISIBLE Or WS_CHILD, 0, 0, PictureBox1.Width, PictureBox1.Height, PictureBox1.Handle.ToInt32, 0)If capDriverConnect(lwndC1, 0) Then
capDlgVideoSource(lwndC1)
capPreviewRate(lwndC1, 66)
capPreview(lwndC1, True)
capSetVideoFormat(lwndC1, bmp, Len(bmp))
SetWindowPos(lwndC1, 0, 0, 0, bmp.bmiHeader.biWidth, bmp.bmiHeader.biHeight, SWP_NOMOVE Or SWP_NOZORDER)
ListBox1.Items.Add(DriverName.Trim)End IfFunction capDlgVideoSource(ByVal lwnd As Long) As Boolean
capDlgVideoSource = SendMessage(lwnd, WM_CAP_DLG_VIDEOSOURCE, 0, 0)
End Function其中:
Public Const WM_CAP_START As Integer = WM_USER
Public Const WM_CAP_DLG_VIDEOSOURCE As Integer = WM_CAP_START + 42
VBFixedStringAttribute lpszName = new VBFixedStringAttribute(100);
int i = 0;
string DriverName = Strings.Space(80);
string DriverVersion = Strings.Space(80);
BITMAPINFO bmp = default(BITMAPINFO);
{
bmp.bmiHeader.biSize = Strings.Len(bmp.bmiHeader);
bmp.bmiHeader.biWidth = 320;
bmp.bmiHeader.biHeight = 240;
bmp.bmiHeader.biPlanes = 1;
bmp.bmiHeader.biBitCount = 24;
}
i = 0;
//摄像头所在的组号
capGetDriverDescriptionA(i, DriverName, 80, DriverVersion, 80);
lwndC1 = capCreateCaptureWindowA(DriverName, WS_VISIBLE | WS_CHILD, 0, 0, PictureBox1.Width, PictureBox1.Height, PictureBox1.Handle.ToInt32, 0);
if (capDriverConnect(lwndC1, 0)) {
capDlgVideoSource(lwndC1);
capPreviewRate(lwndC1, 66);
capPreview(lwndC1, true);
capSetVideoFormat(lwndC1, bmp, Strings.Len(bmp));
SetWindowPos(lwndC1, 0, 0, 0, bmp.bmiHeader.biWidth, bmp.bmiHeader.biHeight, SWP_NOMOVE | SWP_NOZORDER);
ListBox1.Items.Add(DriverName.Trim);
}
}public bool capDlgVideoSource(long lwnd)
{
return SendMessage(lwnd, WM_CAP_DLG_VIDEOSOURCE, 0, 0);
}其中:
public const int WM_CAP_START = WM_USER;
public const int WM_CAP_DLG_VIDEOSOURCE = WM_CAP_START + 42;以后要VB.NET->C#就到这里:
http://www.developerfusion.com/tools/convert/vb-to-csharp/
C#->VB.NET就到这里:
http://www.developerfusion.com/tools/convert/csharp-to-vb/
-------------------------
程序集: Microsoft.VisualBasic(在 Microsoft.VisualBasic.dll 中)