activeX DLL 的编译问题

ly012659 ly012659 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
问题描述:
我在一个activeX dll中定义了一个类,将这个类作为其他各个dll与客户程序标志变量的公共载体,全局变量
在类中定义了一个timer 类型的变量g_timer2,以及一个control类型的变量g_MSCOMM,它作为一个对客户程序mscomm控件的引用,在其他dll中以及客户程序中都对该类在主程序中的对象进行了引用.在调试过程中,没有出现问题.
现在对该类进行编译,第一次在编译时选择no compatibility选项,生成gf.dll,二次编译选择binary compatibility选项,这时弹出'g_MSCOMM' in the 'Globalflags'class module has arguments and/or a return type that is incompatible with a similar declaration in the version compatible component.

Original definition:
Public g_MSCOMM As Object

Current definition:
Public g_MSCOMM As Control

Original definition:
Property Set g_MSCOMM(ByVal RHS As Object)

Current definition:
Public g_MSCOMM As Control

然后有两个选项 break compatibility 和 preserve compatibility

g_timer2也会出现同样的提示

我不明白究竟是哪里出了问题,这个向后兼容性究竟应该注意什么?我前后两次程序并没改动什么,g_MSCOMM,g_timer2的定义有问题吗?

Option Explicit
Public Offline As Boolean
Public SendingMsg As Boolean
Public SendAll As Boolean
Public langflag As Integer
Public FinishULData As Boolean
Public Iniflag As Boolean
Public FinishFlag As Boolean
Public PressStop As Boolean

Public Almshow As Boolean
Public SendFile As Boolean
Public AllowMoni As Boolean
Public FinishMoni As Boolean
Public SendPara As Boolean
Public Addr As Integer
Public addrStr1 As String
Public addrRecieve As String
Public ParaTabShow As Boolean

Public TestStyle As Integer
Public SparaExist As Boolean
Public reqTest As Boolean
Public DatAddr03 As String

Public coderight As Boolean
Public coderight1 As Boolean
Public ResumeFlag As Boolean
Public fftFlag As Boolean

Public message As String
Public AdjFlag As Integer
Public ServoType As String
Public TimerCount As Integer

Public g_MSCOMM As Control
Public g_Timer2 As Timer


Public MDIhwnd As Long
Public SpecialShow As Boolean
Public PhaseShow As Boolean
Public OperationShow As Boolean
Public LoadingShow As Boolean
Public JOGShow As Boolean
Public InertiaShow As Boolean
Public HandShow As Boolean
Public DMShow As Boolean
Public IMShow As Boolean
Public ScopeShow As Boolean

Public fftCmdShow As Boolean
Public fftGraphicShow As Boolean
Public testCmdShow As Boolean
Public testGraphicShow As Boolean
Public testParaShow As Boolean

Public Cn As ADODB.Connection

Public Function ProcessContinue(ByVal hwnd As Long) As Boolean
If Not FinishULData Then
If Not PressStop Then
ProcessContinue = False
MessageBoxEx hwnd, "UpLoad Plot Data", , MB_OK Or MB_ICONINFORMATION, LANG_ENGLISH
Exit Function
End If
End If

If SendPara Then
ProcessContinue = False
MessageBoxEx hwnd, "SendPara", ,MB_OK Or MB_ICONINFORMATION, LANG_ENGLISH
Exit Function
End If

If fftFlag Then
ProcessContinue = False
MessageBoxEx hwnd, "fftFlag", , MB_OK Or MB_ICONINFORMATION, LANG_ENGLISH
Exit Function
End If


ProcessContinue = True

End Function

Public Sub SendingMessage(ByVal msg As String)

Dim Out1() As Byte
Dim Lrc As Long
Dim a As Integer
Dim L As Integer

SendingMsg = True

msg = addrStr1 & msg
L = Len(msg)
Dim i As Integer
Lrc = 0

For i = 0 To L / 2 - 1
a = Val("&H" & Mid(msg, 2 * i + 1, 2))
Lrc = a + Lrc
Next

Lrc = Lrc Mod 256
Lrc = 256 - Lrc

If Lrc = 256 Then
Lrc = 0
End If

ReDim Out1(L + 4) As Byte
For i = 1 To L
Out1(i) = Asc(Mid(msg, i, 1))
Next i

If Lrc < 16 Then
Out1(L + 1) = Asc(Mid("0" & Hex(Lrc), 1, 1))
Out1(L + 2) = Asc(Mid("0" & Hex(Lrc), 2, 1))
Else
Out1(L + 1) = Asc(Mid(Hex(Lrc), 1, 1))
Out1(L + 2) = Asc(Mid(Hex(Lrc), 2, 1))
End If

Out1(0) = Asc(":")
Out1(L + 3) = &HD
Out1(L + 4) = &HA

If g_MSCOMM.PortOpen = True Then
g_MSCOMM.OutBufferCount = 0
g_MSCOMM.Output = Out1 '
End If

End Sub

...全文

相关推荐

评论 11
收藏 已收藏
分享
返回顶部
ly012659
COM/DCOM/COM+ 864 成员 3,658 内容