在VB中可以这样写:
Private Sub mocha_TransferEvent(ByVal camNo As Long, ByVal objectHandle As Long, ByVal headerSize As Long, ByVal imageSize As Long, ByVal formatCode As Long, ByVal result As Long)
Dim pBuf() As Byte
If camNo = 0 Then
Label5.Visible = True
ProgressBar1.Visible = True
Text2.Text = Str(imageSize)
ReDim pBuf(imageSize)
mocha.GetImage camNo, objectHandle, pBuf, imageSize, 0
FileName = Replace(Now(), ":", "-"
+ ".JPG"
Open FileName For Binary Access Write As #1
Put #1, , pBuf
Close #1
mocha.Capture 0, PRM_PRESS_OFF
Command2_Click
Label5.Visible = False
ProgressBar1.Visible = False
Command1.Enabled = True
Else
MsgBox ("没有找到相机"
End If
End Sub