
Machine Vision Camera SDK (DotNet) Developer Guide
Dim stDeviceInfoList As MyCamera.MV_CC_DEVICE_INFO_LIST = New MyCamera.MV_CC_DEVICE_INFO_LIST
Dim cbCallback As MyCamera.cbEventdelegateEx = New MyCamera.cbEventdelegateEx(AddressOf
cbEventdelegateFunc)
'Enumerate device
nRet = dev.MV_CC_EnumDevices_NET((MyCamera.MV_GIGE_DEVICE Or MyCamera.MV_USB_DEVICE),
stDeviceInfoList)
If MyCamera.MV_OK <> nRet Then
Console.WriteLine("Enumerating device failed:{0:x8}", nRet)
Return
End If
If (0 = stDeviceInfoList.nDeviceNum) Then
Console.WriteLine("No Find Gige | Usb Device !")
Return
End If
'Print device information
Dim i As Int32
For i = 0 To stDeviceInfoList.nDeviceNum - 1
Dim stDeviceInfo As MyCamera.MV_CC_DEVICE_INFO = New MyCamera.MV_CC_DEVICE_INFO
stDeviceInfo = CType(Marshal.PtrToStructure(stDeviceInfoList.pDeviceInfo(i),
GetType(MyCamera.MV_CC_DEVICE_INFO)), MyCamera.MV_CC_DEVICE_INFO)
If (MyCamera.MV_GIGE_DEVICE = stDeviceInfo.nTLayerType) Then
Dim stGigeInfoPtr As IntPtr = Marshal.AllocHGlobal(216)
Marshal.Copy(stDeviceInfo.SpecialInfo.stGigEInfo, 0, stGigeInfoPtr, 216)
Dim stGigeInfo As MyCamera.MV_GIGE_DEVICE_INFO
stGigeInfo = CType(Marshal.PtrToStructure(stGigeInfoPtr, GetType(MyCamera.MV_GIGE_DEVICE_INFO)),
MyCamera.MV_GIGE_DEVICE_INFO)
Dim nIpByte1 As UInt32 = (stGigeInfo.nCurrentIp And &HFF000000) >> 24
Dim nIpByte2 As UInt32 = (stGigeInfo.nCurrentIp And &HFF0000) >> 16
Dim nIpByte3 As UInt32 = (stGigeInfo.nCurrentIp And &HFF00) >> 8
Dim nIpByte4 As UInt32 = (stGigeInfo.nCurrentIp And &HFF)
Info = "DEV[" + Convert.ToString(i) + "] NAME[" + stGigeInfo.chUserDefinedName + "]IP[" + nIpByte1.ToString() +
"." + nIpByte2.ToString() + "." + nIpByte3.ToString() + "." + nIpByte4.ToString() + "]"
Console.WriteLine(Info)
Else
Dim stUsbInfoPtr As IntPtr = Marshal.AllocHGlobal(540)
Marshal.Copy(stDeviceInfo.SpecialInfo.stUsb3VInfo, 0, stUsbInfoPtr, 540)
Dim stUsbInfo As MyCamera.MV_USB3_DEVICE_INFO
stUsbInfo = CType(Marshal.PtrToStructure(stUsbInfoPtr, GetType(MyCamera.MV_USB3_DEVICE_INFO)),
MyCamera.MV_USB3_DEVICE_INFO)
Info = "DEV[" + Convert.ToString(i) + "] NAME[" + stUsbInfo.chUserDefinedName + "]Model[" +
stUsbInfo.chSerialNumber + "]"
Console.WriteLine(Info)
End If
Next
Console.WriteLine("please select a device")
Dim nIndex As Int32
nIndex = Console.ReadLine()
Dim stdevInfo As MyCamera.MV_CC_DEVICE_INFO
stdevInfo = CType(Marshal.PtrToStructure(stDeviceInfoList.pDeviceInfo(nIndex),
GetType(MyCamera.MV_CC_DEVICE_INFO)), MyCamera.MV_CC_DEVICE_INFO)
63






















































































































































































































































































































































































































































































































































































































