VB中如何调用PI_Mercury_GCS_DLL.dll这个DLL文件,并进行RS232连接。
下面是RS232连接部分的代码:
#ifndef _GENERIC_I_NO_GUI
int MERCURY_FUNC_DECL Mercury_InterfaceSetupDlg(const char* szRegKeyName);
#endif
int MERCURY_FUNC_DECL Mercury_ConnectRS232(int port, int baudrate);
BOOL MERCURY_FUNC_DECL Mercury_IsConnected(int ID);
void MERCURY_FUNC_DECL Mercury_CloseConnection(int ID);
int MERCURY_FUNC_DECL Mercury_GetError(int ID);
BOOL MERCURY_FUNC_DECL Mercury_SetErrorCheck(int ID, BOOL bErrorCheck);
BOOL MERCURY_FUNC_DECL Mercury_TranslateError(int errNr, char* szBuffer, int maxlen);
下面是RS232连接部分的代码:
#ifndef _GENERIC_I_NO_GUI
int MERCURY_FUNC_DECL Mercury_InterfaceSetupDlg(const char* szRegKeyName);
#endif
int MERCURY_FUNC_DECL Mercury_ConnectRS232(int port, int baudrate);
BOOL MERCURY_FUNC_DECL Mercury_IsConnected(int ID);
void MERCURY_FUNC_DECL Mercury_CloseConnection(int ID);
int MERCURY_FUNC_DECL Mercury_GetError(int ID);
BOOL MERCURY_FUNC_DECL Mercury_SetErrorCheck(int ID, BOOL bErrorCheck);
BOOL MERCURY_FUNC_DECL Mercury_TranslateError(int errNr, char* szBuffer, int maxlen);
解决方案 »
- 问个关于窗口的问题
- 请问怎么把RichTextBox中的数据和格式一起存在Sql Server中,和如何读出显示到RichTextBox
- 最基本的最简单的代码 Open StaSysDbsName For Random As FileNum Len = ffhhjd
- 请教关于控制外部程序菜单的问题
- 如何将WebBrowser内的网页保存到指定目录?
- 在VB的exe工程里如果调用word中的“插入符号”和“插入公式”对话框?
- 我用的工控软件WINCC6。0中内嵌了VBS,但我不知如何用VBS中的语句来实现屏幕硬拷贝!
- 我用Exclusive=yes的方式打开dbf后,不能再用Exclusive=no的方式再开一个conn写数据?
- 谁能给我一个jpg图片压缩的原程序啊!
- 我不知道还该不该继续支持微软
- 关于list项目排除相同项目的问题|||在线等待|||
- 发一个UUE(二进制转换为文本格式)的工具代码
#If Not GENERIC_I_NO_GUI Then
'int MERCURY_FUNC_DECL Mercury_InterfaceSetupDlg(const char* szRegKeyName);
Private Declare Function Mercury_InterfaceSetupDlg Lib "PI_Mercury_GCS_DLL.dll" (ByVal szRegKeyName As String) As Long
#End If
'int MERCURY_FUNC_DECL Mercury_ConnectRS232(int port, int baudrate);
Private Declare Function Mercury_ConnectRS232 Lib "PI_Mercury_GCS_DLL.dll" (ByVal port As Long, ByVal baudrate As Long) As Long
'BOOL MERCURY_FUNC_DECL Mercury_IsConnected(int ID);
Private Declare Function Mercury_IsConnected Lib "PI_Mercury_GCS_DLL.dll" (ByVal ID As Long) As Long
'void MERCURY_FUNC_DECL Mercury_CloseConnection(int ID);
Private Declare Sub Mercury_CloseConnection Lib "PI_Mercury_GCS_DLL.dll" (ByVal ID As Long)
'int MERCURY_FUNC_DECL Mercury_GetError(int ID);
Private Declare Function Mercury_GetError Lib "PI_Mercury_GCS_DLL.dll" (ByVal ID As Long) As Long
'BOOL MERCURY_FUNC_DECL Mercury_SetErrorCheck(int ID, BOOL bErrorCheck);
Private Declare Function Mercury_SetErrorCheck Lib "PI_Mercury_GCS_DLL.dll" (ByVal ID As Long, ByVal bErrorCheck As Long) As Long
'BOOL MERCURY_FUNC_DECL Mercury_TranslateError(int errNr, char* szBuffer, int maxlen);
Private Declare Function Mercury_TranslateError Lib "PI_Mercury_GCS_DLL.dll" (ByVal errNr As Long, ByVal szBuffer As String, ByVal maxlen As Long) As Long
Private Declare Function Mercury_MVR Lib "PI_Mercury_GCS_DLL.dll" (ByVal ID As Long, ByVal szAxes As String, ByVal pdValarray As Double) As Long我执行控件操作,我试了下,按照这样不行:
Private Sub Command9_Click()
Dim ID As Long
ID = Mercury_ConnectRS232(2, 9600)
MSComm1.Output = Mercury_MVR(ID, "A", -146) & Chr(13)
'或者干脆Mercury_MVR(ID, "A", -146) & Chr(13)
End Sub
应该怎么改呢。
Private Declare Function Mercury_MVR Lib "PI_Mercury_GCS_DLL.dll" (ByVal ID As Long, ByVal szAxes As String, ByVal pdValarray As Double) As Long
Private Sub Command9_Click()
Call Sleep(100)
Mercury_MVR.A = 146 'A即szAxes ,146即pdValarray
Dim currentPos As Double
currentPos = Mercury_MVR.A
End Sub
这样也不行!为什么?