日前在網路上找到人家分享的程式 小弟照做後發現出現錯誤
在此想請教大大幫忙解惑

小的不明白是甚麼意思 有大大可以幫我解惑嗎??
奉上完整程式碼與來源
Imports System.Runtime.InteropServices
Public Class MainForm
#Region "參數設定"
Const WM_CAP As Short = &H400S
Const WM_CAP_DRIVER_CONNECT As Integer = WM_CAP + 10
Const WM_CAP_DRIVER_DISCONNECT As Integer = WM_CAP + 11
Const WM_CAP_EDIT_COPY As Integer = WM_CAP + 30
Const WM_CAP_DLG_VIDEOFORMAT As Integer = WM_CAP + 41
Const WM_CAP_GET_VIDEOFORMAT As Integer = WM_CAP + 44
Const WM_CAP_SET_VIDEOFORMAT As Integer = WM_CAP + 45
Const WM_CAP_SET_PREVIEW As Integer = WM_CAP + 50
Const WM_CAP_SET_PREVIEWRATE As Integer = WM_CAP + 52
Const WM_CAP_SET_SCALE As Integer = WM_CAP + 53
Const WM_CAP_SAVEDIB As Integer = WM_CAP + 25
Const WM_CAP_FILE_SET_CAPTURE_FILEA As Integer = WM_CAP + 20
Const WM_CAP_SEQUENCE As Integer = WM_CAP + 62
Const WM_CAP_STOP As Integer = WM_CAP + 68
Const WS_CHILD As Integer = &H40000000
Const WS_VISIBLE As Integer = &H10000000
Const SWP_NOMOVE As Short = &H2S
Const SWP_NOSIZE As Short = 1
Const SWP_NOZORDER As Short = &H4S
Const HWND_BOTTOM As Short = 1
Dim iDevice As Integer = 0
Dim hHwnd As Integer
#End Region
#Region "Declare Function"
Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, _
ByVal lParam As Object) As Integer
Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" (ByVal hwnd As Integer, _
ByVal hWndInsertAfter As Integer, ByVal x As Integer, ByVal y As Integer, _
ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer) As Integer
Declare Function DestroyWindow Lib "user32" (ByVal hndw As Integer) As Boolean
Declare Function capCreateCaptureWindowA Lib "avicap32.dll" _
(ByVal lpszWindowName As String, ByVal dwStyle As Integer, _
ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, _
ByVal nHeight As Short, ByVal hWndParent As Integer, _
ByVal nID As Integer) As Integer
#End Region
Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Button2.Enabled = False
Button3.Enabled = False
Button4.Enabled = False
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'開啟視訊
hHwnd = capCreateCaptureWindowA(0, WS_VISIBLE Or WS_CHILD, 0, 0, 320, 240, PictureBox1.Handle.ToInt32, 0)
If SendMessage(hHwnd, WM_CAP_DRIVER_CONNECT, 0, 0) Then
SendMessage(hHwnd, WM_CAP_SET_VIDEOFORMAT, 0, 0)
SendMessage(hHwnd, WM_CAP_SET_SCALE, True, 0)
SendMessage(hHwnd, WM_CAP_SET_PREVIEWRATE, 66, 0)
SendMessage(hHwnd, WM_CAP_SET_PREVIEW, True, 0)
Button2.Enabled = True
Button3.Enabled = True
Button4.Enabled = True
Else
DestroyWindow(hHwnd)
MsgBox("視訊未連接")
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'關閉視訊
SendMessage(hHwnd, WM_CAP_DRIVER_DISCONNECT, iDevice, 0)
DestroyWindow(hHwnd)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'拍照
SendMessage(hHwnd, WM_CAP_SAVEDIB, 0, "c:\text.bmp")
MsgBox("圖片已存至c:\text.bmp")
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
'設定
SendMessage(hHwnd, WM_CAP_DLG_VIDEOFORMAT, 0, 0)
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
'刪除照片
Dim fileExists As Boolean = _
My.Computer.FileSystem.FileExists("c:\text.bmp")
If fileExists Then
My.Computer.FileSystem.DeleteFile("c:\text.bmp")
MsgBox("text.bmp圖片已刪除!")
End If
End Sub
End Class
http://tw.myblog.yahoo.com/jw!8q9xF8OBGBhbpQBj5MJvplAYnLc-/article?mid=25




























































































