VB调用dll内存不可读,哪位高手可以帮帮小弟我啊有时候不会出现,有时候会出现
VB调用dll内存不可读,谁可以帮帮我啊?有时候不会出现,有时候会出现。
Public Function mySearching(ByVal mode As Long, ByVal search_ip As Long) As Long
Dim i As Long
Dim ret As Long
Dim retcnt As Long
For i = 0 To search_count
If (i < search_count) Then
If (mySearchInfo(i).dshdl >= 0) Then
dsc_Detach (mySearchInfo(i).dshdl)
End If
Exit Function
End If
Next i
searcg_count = 0
Call dsc_SetSearchOpt(SEARCH_TIMEOUT, SEARCH_RETRY_CNT)
If (mode = BROADCAST) Then
If ((ret = dsc_EnumSearch(0, AddressOf myEnumSearchProc)) <> DSC_OK) Then '出错
txtstring = "dsc_EnumSearch() fail, error code: & ret &" & txtstring
'Exit Function
End If
If (search_count <= 0) Then
MsgBox "No Network Enabler found !" & txtstring
txtstring = "-1"
'Exit Function
End If
End If
For i = 0 To search_count
If i < search_count Then
If ((ret = dsc_Attach(mySearchInfo(i).ds_info, VarPtr(mySearchInfo(i).ds_info))) <> DSC_OK) Then ''出错
txtstring = "dsc_Attach() fail, error code: &ret&" & txtstring
' Exit Function
End If
'Get ip address, netmask, gateway
' SearchInfo(i).p_ifconfig = new ifconfiginfo
If ((ret = dsc_GetIfConfig(mySearchInfo(i).dshdl, 1, retcnt, mySearchInfo(i).p_ifconfig)) <> DSC_OK) Then '出错
txtstring = "dsc_GetIfConfig() fail, error code:" & ret & "" & txtstring
'Exit Function
End If
'Get serial interface
If ((ret = dsc_GetSerialInterface(mySearchInfo(i).dshdl, 1, SERINIT, mySearchInfo(i).port_type)) <> DSC_OK) Then ''出错
txtstring = "dsc_GetSerialInterface() fail, error code: & ret&" & txtstring
'Exit Function
End If
'Get serial port baudrate, mode, flowctrl setting
If ((ret = dsc_GetSerialIOCtl(mySearchInfo(i).dshdl, 1, SERINIT, mySearchInfo(i).pserial_info)) <> DSC_OK) Then'出错
txtstring = "dsc_GetSerialIOCtl() fail, error code:" & ret & "" & txtstring
'Exit Function
End If
'Get Server name
If ((ret = dsc_GetName(mySearchInfo(i).dshdl, mySearchInfo(i).svr_name)) <> DSC_OK) Then '出错
txtstring = "dsc_GetName() fail, error code:" & ret & " " & txtstring
'Exit Function
End If
'Get the kernel/firmware information.
If ((ret = dsc_GetKernelInfo(mySearchInfo(i).dshdl, mySearchInfo(i).pkernel_info)) <> DSC_OK) Then'出错
txtstring = "dsc_GetKernelInfo() fail, error code:" & ret & "" & txtstring
'Exit Function
End If
'Get DIO information information.
If ((ret = dsc_GetMaxDIO(mySearchInfo(i).dshdl, mySearchInfo(i).DIO_max)) <> DSC_OK) Then
txtstring = "dsc_GetDIOMode() fail, error code:" & ret & "" & txtstring
'Exit Function
End If
' If ((ret = dsc_GetDIOMode(mySearchInfo(i).dshdl, 0, mySearchInfo(i).DIO_max, mySearchInfo(i).DIO_mode)) <> DSC_OK) Then '
' txtstring = "dsc_GetDIOMode() fail, error code:" & ret & "" & txtstring
' Exit Function
' End If
' If ((ret = dsc_GetDIOState(mySearchInfo(i).dshdl, 0, mySearchInfo(i).DIO_max, mySearchInfo(i).DIO_state)) <> DSC_OK) Then
' txtstring = "dsc_GetDIOState() fail, error code: " & ret & " &txtstring"
Public Function mySearching(ByVal mode As Long, ByVal search_ip As Long) As Long
Dim i As Long
Dim ret As Long
Dim retcnt As Long
For i = 0 To search_count
If (i < search_count) Then
If (mySearchInfo(i).dshdl >= 0) Then
dsc_Detach (mySearchInfo(i).dshdl)
End If
Exit Function
End If
Next i
searcg_count = 0
Call dsc_SetSearchOpt(SEARCH_TIMEOUT, SEARCH_RETRY_CNT)
If (mode = BROADCAST) Then
If ((ret = dsc_EnumSearch(0, AddressOf myEnumSearchProc)) <> DSC_OK) Then '出错
txtstring = "dsc_EnumSearch() fail, error code: & ret &" & txtstring
'Exit Function
End If
If (search_count <= 0) Then
MsgBox "No Network Enabler found !" & txtstring
txtstring = "-1"
'Exit Function
End If
End If
For i = 0 To search_count
If i < search_count Then
If ((ret = dsc_Attach(mySearchInfo(i).ds_info, VarPtr(mySearchInfo(i).ds_info))) <> DSC_OK) Then ''出错
txtstring = "dsc_Attach() fail, error code: &ret&" & txtstring
' Exit Function
End If
'Get ip address, netmask, gateway
' SearchInfo(i).p_ifconfig = new ifconfiginfo
If ((ret = dsc_GetIfConfig(mySearchInfo(i).dshdl, 1, retcnt, mySearchInfo(i).p_ifconfig)) <> DSC_OK) Then '出错
txtstring = "dsc_GetIfConfig() fail, error code:" & ret & "" & txtstring
'Exit Function
End If
'Get serial interface
If ((ret = dsc_GetSerialInterface(mySearchInfo(i).dshdl, 1, SERINIT, mySearchInfo(i).port_type)) <> DSC_OK) Then ''出错
txtstring = "dsc_GetSerialInterface() fail, error code: & ret&" & txtstring
'Exit Function
End If
'Get serial port baudrate, mode, flowctrl setting
If ((ret = dsc_GetSerialIOCtl(mySearchInfo(i).dshdl, 1, SERINIT, mySearchInfo(i).pserial_info)) <> DSC_OK) Then'出错
txtstring = "dsc_GetSerialIOCtl() fail, error code:" & ret & "" & txtstring
'Exit Function
End If
'Get Server name
If ((ret = dsc_GetName(mySearchInfo(i).dshdl, mySearchInfo(i).svr_name)) <> DSC_OK) Then '出错
txtstring = "dsc_GetName() fail, error code:" & ret & " " & txtstring
'Exit Function
End If
'Get the kernel/firmware information.
If ((ret = dsc_GetKernelInfo(mySearchInfo(i).dshdl, mySearchInfo(i).pkernel_info)) <> DSC_OK) Then'出错
txtstring = "dsc_GetKernelInfo() fail, error code:" & ret & "" & txtstring
'Exit Function
End If
'Get DIO information information.
If ((ret = dsc_GetMaxDIO(mySearchInfo(i).dshdl, mySearchInfo(i).DIO_max)) <> DSC_OK) Then
txtstring = "dsc_GetDIOMode() fail, error code:" & ret & "" & txtstring
'Exit Function
End If
' If ((ret = dsc_GetDIOMode(mySearchInfo(i).dshdl, 0, mySearchInfo(i).DIO_max, mySearchInfo(i).DIO_mode)) <> DSC_OK) Then '
' txtstring = "dsc_GetDIOMode() fail, error code:" & ret & "" & txtstring
' Exit Function
' End If
' If ((ret = dsc_GetDIOState(mySearchInfo(i).dshdl, 0, mySearchInfo(i).DIO_max, mySearchInfo(i).DIO_state)) <> DSC_OK) Then
' txtstring = "dsc_GetDIOState() fail, error code: " & ret & " &txtstring"