VB6.0回调函数求助
'public.bas
Option Explicit
Public hPort As Long
Public clock_id As Long
Public started As Boolean
Public callback1 As Long
Public callback2 As Long
Public callback3 As Long
Public serialnum As String
Public mydevid As Integer
Public myip As String
Public myclockid As Integer
Public myclock As Integer
Public myport As Integer
Public mystate As String
Public myrecords As String
Public Sub FunOnDeviceLogin(ByVal Dev_id As Integer, ByVal serial As Long, ByVal ip As Long, ByVal port As Integer, ByRef Heartbeat As Integer)
'回调函数1
Dim hasDevice As Boolean
Dim i As Integer
hasDevice = False
If serialnum = SysAllocString(serial) Then
hasDevice = True
mydevid = Dev_id
myip = SysAllocString(ip)
myport = port
End If
If hasDevice = False Then
myclockid = Dev_id
serialnum = SysAllocString(serial)
myip = SysAllocString(ip)
myport = port
mystate = "登录"
End If
Heartbeat = 2
End Sub
Public Sub FunOnRefreshDeviceStateBySerial(ByVal Dev_id As Integer, ByVal serial As Long, ByVal state As Integer, ByVal RecordCount As Integer)
'回调函数2
Dim a As String
If serialnum = SysAllocString(serial) Then
If state = 0 Then
mystate = "状态:脱机"
Else
mystate = "状态:联机"
End If
End If
End Sub
Public Sub FunOnRecieveBatchRecordBySerialStr(ByVal Dev_id As Integer, ByVal serial As Long, ByVal index As Integer, ByVal RecordCount As Integer, ByVal Records As Long, ByRef bReturnOK As Boolean)
'回调函数3
myrecords = SysAllocString(Records)
bReturnOK = True
End Sub
'delphi中的声明
'procedure SetUpLoadProcStr(vOnDeviceLogin:FunOnDeviceLogin; vOnRefreshDeviceState: FunOnRefreshDeviceStateBySerial; vOnRecieveBatchRecord: FunOnRecieveBatchRecordBySerialStr); stdcall;
Public Declare Sub SetUpLoadProcStr Lib "EastRiver.Dll" (ByVal FunOnDeviceLogin As Long, ByVal FunOnRefreshDeviceStateBySerial As Long, ByVal FunOnRecieveBatchRecordBySerialStr As Long)
'delphi中的声明
'function StartUpLoad(vListenPort:Integer):boolean; stdcall; external 'EastRiver.dll';
Public Declare Function StartUpLoad Lib "EastRiver.Dll" (ByVal port As Long) As Boolean
Declare Function SysAllocString Lib "oleaut32.dll" (ByVal pOlechar As Long) As String调用
Function GetFuncPtr(ByVal Ptr As Long) As Long
GetFuncPtr = Ptr
End Function
Private Sub Command4_Click()
Dim iPort As Integer
callback1 = GetFuncPtr(AddressOf FunOnDeviceLogin)
callback2 = GetFuncPtr(AddressOf FunOnRefreshDeviceStateBySerial)
callback3 = GetFuncPtr(AddressOf FunOnRecieveBatchRecordBySerialStr)
iPort = CInt(Text1.Text)
started = StartUpLoad(iPort)
If started Then
Command5.Enabled = 1
Command4.Enabled = 0
Call SetUpLoadProcStr(VarPtr(callback1), VarPtr(callback2), VarPtr(callback3))
End If
End Sub
...全文
相关推荐
VB6.0安装包
VB6.0的安装包,验证码全部输入1就可以安装了,精典版的
VB6.0运行库
VB6.0运行库 将ZIP解压后,放在系统盘(C:)下WINDOWS\SYSTEM32下即可。
VB6.0详细讲义(VB6实用教程_VB6从入门到精通)
第一章 Visual Basic介绍 第二章 用户界面设计 第三章 编程的基础(含变量,常量,条件语句,循环语句,自定义变量,自定义过程,对象和类等基础) 第四章 Windows 95的新控件Visual Basic的输入输出 第五章 Visual Basic的鼠标事件和绘图 第六章 Visual Basic的数据库、报表、预览、打印 第七章 从文件中存取资料 第八章 发行应用程序 第九章 使用Windows API和用Visual Basic建立自己的屏幕保护程序 第十章 创建ActiveX控件 第十一章 ActiveX文档 第十二章 用对象链接与嵌入(OLE)扩展Visual Basic 第十三章 使用资源文件 第十四章 用Visual Basic建立ActiveX DLL 第十五章 用Winsock控件进行Internet通信 第十六章 Web浏览控件
VB6.0SP6补丁
配合win7不卡的VB6,实现win7中VB界面不卡
VB6.0迷你版(VB6.1底层版和VB6.0精简版二合一)
VB6.0迷你版(VB6.1底层版和VB6.0精简版二合一),这个版本的VB里面有一些VB窗口DLL等底层编程的代码。适合用VB搞底层开发做游戏辅助或修改器的朋友。


API
