我连接一台DOBOT机器臂,使用它们的DLL,在VS2015中,把项目属性改为.net 2.0,目标CPU设置为X86后,可以正常连接调用。但是把这几个DLL拷贝到foxtable安装目录下,然后全局代码中使用<DllImport>引用API函数,在代码中直接调用这些函数时,foxtable没报任何错,直接关闭退出
在vs2015中
DobotDll.vb :
Imports System.Runtime.InteropServices
Namespace VBdemo
Public Class DobotDll
<DllImport("DobotDll.dll", CallingConvention:=CallingConvention.Cdecl)> Public Shared Function ConnectDobot(ByVal portName As String, ByVal baudrate As Int32) As Int32
End Function
End Class
End Namespace
Form1.vb :
Imports test01.VBdemo
Public Class Form1
Dim result As Integer
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
result = DobotDll.ConnectDobot("", 115200)
If result <> 0 Then
MsgBox("Could not find Dobot or Dobot is occupied!")
Return
Else
MsgBox("连接成功!")
End If
End Sub
End Class
在foxtable中,
此主题相关图片如下:image 1.jpg
然后,直接MessageBox.Show(ConnectDobot("", 115200))
foxtable不报错,直接关闭退出
[此贴子已经被作者于2017/12/5 11:39:02编辑过]