网上找的,利用切贴板'窗体代码 Private Declare Function SendMessage Lib "USER32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Declare Function capCreateCaptureWindow Lib "avicap32.dll" Alias "capCreateCaptureWindowA" (ByVal lpszWindowName As String, ByVal dwStyle As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hwndParent As Long, ByVal nID As Long) As Long Private Const GET_FRAME As Long = 1084 Private Const COPY As Long = 1054 Private Const CONNECT As Long = 1034 Private Const DISCONNECT As Long = 1035 Private CapHwnd As Long Private Sub Command1_Click() '开始 CapHwnd = capCreateCaptureWindow("WebcamCapture", 0, 0, 0, 640, 480, Me.hwnd, 0) DoEvents SendMessage CapHwnd, 1034, 0, 0 Timer1.Enabled = True End Sub Private Sub Command2_Click() '暂停 DoEvents SendMessage CapHwnd, 1035, 0, 0 Timer1.Enabled = False End Sub Private Sub Timer1_Timer() 'timer1.Interval=50 On Error Resume Next SendMessage CapHwnd, 1084, 0, 0 SendMessage CapHwnd, 1054, 0, 0 Picture1.Picture = Clipboard.GetData Clipboard.Clear End Sub
Private Declare Function SendMessage Lib "USER32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function capCreateCaptureWindow Lib "avicap32.dll" Alias "capCreateCaptureWindowA" (ByVal lpszWindowName As String, ByVal dwStyle As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hwndParent As Long, ByVal nID As Long) As Long
Private Const GET_FRAME As Long = 1084
Private Const COPY As Long = 1054
Private Const CONNECT As Long = 1034
Private Const DISCONNECT As Long = 1035
Private CapHwnd As Long
Private Sub Command1_Click() '开始
CapHwnd = capCreateCaptureWindow("WebcamCapture", 0, 0, 0, 640, 480, Me.hwnd, 0)
DoEvents
SendMessage CapHwnd, 1034, 0, 0
Timer1.Enabled = True
End Sub
Private Sub Command2_Click() '暂停
DoEvents
SendMessage CapHwnd, 1035, 0, 0
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer() 'timer1.Interval=50
On Error Resume Next
SendMessage CapHwnd, 1084, 0, 0
SendMessage CapHwnd, 1054, 0, 0
Picture1.Picture = Clipboard.GetData
Clipboard.Clear
End Sub
不要做A语言代码修改为B语言代码的无用功。
也不要做用A语言代码直接调用B语言代码库这样复杂、这样容易出错的傻事。
只需让A、B语言代码的输入输出重定向到文本文件,或修改A、B语言代码让其通过文本文件输入输出。
即可很方便地让A、B两种语言之间协调工作。