Hi all,
I wrote a testing program in VB6 (Ref below for the entire code) to test the compatibilty of a VB6 program on the latest Rightfax patch (V9.3 Feature Pack 2 Service Release 5 - RFCOMAPI.DLL v9.3.2.553). It runs alright without handling events (e.g. new fax events), but it crashes in about 15 sec when I turn on the "Event Handling" option. (NOTE: This program runs perfectly on Rightfax V8.5 SP4 (RFCOMAPI.DLL v8.6.0.106). Any ideas or input are appreciated, thanks !
Code here:
VERSION 5.00
Begin VB.Form frmMain
AutoRedraw = -1 'True
Caption = "Rightfax Test Client (VB6)"
ClientHeight = 7830
ClientLeft = 60
ClientTop = 405
ClientWidth = 9705
LinkTopic = "Form1"
ScaleHeight = 7830
ScaleWidth = 9705
StartUpPosition = 3 'Windows Default
Begin VB.CheckBox ChkEventHandle
Caption = "Event Handling"
Height = 255
Left = 1200
TabIndex = 33
Top = 840
Width = 2055
End
Begin VB.Timer myTimer
Enabled = 0 'False
Interval = 1000
Left = 120
Top = 120
End
Begin VB.Frame Frame3
Caption = "New Fax Event Monitoring"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 2415
Left = 4080
TabIndex = 24
Top = 1920
Width = 5175
Begin VB.CommandButton btnClearEvents
Caption = "Clear Events"
Height = 375
Left = 3120
TabIndex = 26
Top = 240
Width = 1695
End
Begin VB.ListBox lstEvents
BeginProperty Font
Name = "Courier New"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 1320
Left = 240
TabIndex = 25
Top = 720
Width = 4695
End
Begin VB.Label lbMonitoredUser
Height = 255
Left = 600
TabIndex = 27
Top = 360
Width = 2175
End
End
Begin VB.Frame FrServerInfo
Caption = "Server Info"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 2415
Left = 480
TabIndex = 13
Top = 1920
Width = 3375
Begin VB.Label lbChannelNo
Height = 255
Left = 1800
TabIndex = 23
Top = 1920
Width = 975
End
Begin VB.Label lbServerType
Height = 255
Left = 1800
TabIndex = 22
Top = 1200
Width = 975
End
Begin VB.Label Label13
AutoSize = -1 'True
Caption = "Licensed Channels:"
Height = 195
Left = 330
TabIndex = 21
Top = 1920
Width = 1395
End
Begin VB.Label lbSerialNo
Height = 255
Left = 1800
TabIndex = 20
Top = 1560
Width = 975
End
Begin VB.Label lbVersion
Height = 255
Left = 1800
TabIndex = 19
Top = 840
Width = 975
End
Begin VB.Label lbServerName
Height = 255
Left = 1800
TabIndex = 18
Top = 480
Width = 1455
End
Begin VB.Label Label9
AutoSize = -1 'True
Caption = "Serial #:"
Height = 195
Left = 330
TabIndex = 17
Top = 1560
Width = 585
End
Begin VB.Label Label8
AutoSize = -1 'True
Caption = "Server Name:"
Height = 195
Left = 330
TabIndex = 16
Top = 480
Width = 975
End
Begin VB.Label Label7
AutoSize = -1 'True
Caption = "COMAPI Version:"
Height = 195
Left = 330
TabIndex = 15
Top = 1200
Width = 1230
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "Version:"
Height = 195
Left = 330
TabIndex = 14
Top = 840
Width = 570
End
End
Begin VB.Frame Frame1
Caption = "Users and Faxes"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 3135
Left = 480
TabIndex = 7
Top = 4440
Width = 8775
Begin VB.ListBox lst_Users
Height = 1815
Left = 240
TabIndex = 9
Top = 720
Width = 2535
End
Begin VB.ListBox lst_FaxList
BeginProperty Font
Name = "Courier New"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 1740
Left = 2880
TabIndex = 8
Top = 720
Width = 5655
End
Begin VB.Label Label14
AutoSize = -1 'True
Caption = "User ID"
Height = 195
Left = 360
TabIndex = 31
Top = 480
Width = 540
End
Begin VB.Label Label12
Caption = "Fax ID"
Height = 255
Left = 3000
TabIndex = 30
Top = 480
Width = 1095
End
Begin VB.Label Label11
AutoSize = -1 'True
Caption = "Error DNIS"
Height = 195
Left = 5900
TabIndex = 29
Top = 480
Width = 990
End
Begin VB.Label Label10
AutoSize = -1 'True
Caption = "Status"
Height = 195
Left = 5325
TabIndex = 28
Top = 480
Width = 450
End
Begin VB.Label Label2
Caption = "User Name"
Height = 255
Left = 1680
TabIndex = 12
Top = 480
Width = 855
End
Begin VB.Label Label3
Caption = "Total Fax ="
Height = 255
Left = 6720
TabIndex = 11
Top = 2640
Width = 975
End
Begin VB.Label lbTotalFax
Caption = "0"
Height = 255
Left = 7800
TabIndex = 10
Top = 2640
Width = 495
End
End
Begin VB.CommandButton btnConnect
Caption = "Connect"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 1095
Left = 7200
TabIndex = 6
Top = 240
Width = 1695
End
Begin VB.TextBox edPassword
Height = 375
IMEMode = 3 'DISABLE
Left = 5160
PasswordChar = "*"
TabIndex = 2
Top = 840
Width = 1455
End
Begin VB.TextBox edLogin
Height = 375
Left = 5160
TabIndex = 1
Text = "Administrator"
Top = 240
Width = 1455
End
Begin VB.TextBox edRFServer
Height = 375
Left = 1920
TabIndex = 0
Top = 240
Width = 1455
End
Begin VB.Label lbConnectTime
AutoSize = -1 'True
Caption = "Disconnected Status"
Height = 195
Left = 2580
TabIndex = 32
Top = 1440
Width = 1485
End
Begin VB.Line Line1
X1 = 480
X2 = 9240
Y1 = 1620
Y2 = 1620
End
Begin VB.Label Label6
Caption = "Password"
Height = 375
Left = 4200
TabIndex = 5
Top = 840
Width = 975
End
Begin VB.Label Label5
Caption = "Login:"
Height = 375
Left = 4200
TabIndex = 4
Top = 360
Width = 855
End
Begin VB.Label Label4
Caption = "RF Server:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 840
TabIndex = 3
Top = 360
Width = 975
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public gl_Connect As Boolean
Public gl_MyFaxServer As RFCOMAPILib.FaxServer
Private WithEvents MyFaxServerEventHandler As RFCOMAPILib.FaxServer
Attribute MyFaxServerEventHandler.VB_VarHelpID = -1
Private rfEvents As RFCOMAPILib.Events
Private gl_startDateTime
Private gl_FormTitle As String
Private Sub Form_Load()
gl_FormTitle = "Rightfax Test Client (VB6)"
CleanUIElements
End Sub
Private Sub Form_Unload(Cancel As Integer)
If Not IsObject(gl_MyFaxServer) Then
gl_MyFaxServer.CloseServer
End If
End Sub
Private Sub btnConnect_Click()
If gl_Connect Then
' Disconnect RF Server
Disconnect
Else
' Connect RF Server
Connect
End If
End Sub
Private Sub btnClearEvents_Click()
lstEvents.Clear
End Sub
Private Sub ChkEventHandle_Click()
SetEventsUIElements
End Sub
Private Sub lst_Users_Click()
Dim objUser As RFCOMAPILib.User
Dim objFax As RFCOMAPILib.Fax
Dim strMsg As String
Dim strFaxID As String, strTotalPage As String, strErrCode As String, strFaxStatus As String
Set objUser = gl_MyFaxServer.Users(lst_Users.ListIndex + 1)
lst_FaxList.Clear
' Populate the fax list
For Each objFax In gl_MyFaxServer.Faxes(objUser.ID)
' fax record in a format of: e.g. DCA07288186914: 4 pgs Ok None
strMsg = Left(objFax.UniqueID & ": ", 17) & objFax.TotalPages & " pgs " & whatFaxStatus(objFax.FaxStatus)
strMsg = strMsg & " " & whatErrorCode(objFax.FaxErrorCode) & " " & Trim(objFax.BillingCode2)
lst_FaxList.AddItem strMsg
Next
lbTotalFax.Caption = lst_FaxList.ListCount
End Sub
Public Sub MyFaxServerEventHandler_OnNewFaxEvent(ByVal NewFax As RFCOMAPILib.Fax)
Dim strMsg As String
Dim currentTime
strMsg = TimeStamp & "> " & NewFax.UniqueID & ": " & NewFax.TotalPages & " pgs " & whatFaxStatus(NewFax.FaxStatus) & " "
strMsg = strMsg & whatErrorCode(NewFax.FaxErrorCode)
lstEvents.AddItem strMsg
End Sub
Private Sub Disconnect()
gl_MyFaxServer.CloseServer
CleanUIElements
gl_Connect = False
stopTimer
End Sub
Private Sub CleanUIElements()
edRFServer.Enabled = True
edLogin.Enabled = True
edPassword.Enabled = True
ChkEventHandle.Enabled = True
btnConnect.Caption = "Connect"
lst_Users.Clear
lst_FaxList.Clear
lstEvents.Clear
lbTotalFax.Caption = lst_FaxList.ListCount
lbMonitoredUser.Caption = ""
SetEventsUIElements
lbConnectTime.Caption = "_"
lbServerName.Caption = ""
lbServerType.Caption = ""
lbVersion.Caption = ""
lbChannelNo.Caption = ""
lbSerialNo.Caption = ""
End Sub
Private Sub SetEventsUIElements()
If (ChkEventHandle.Value) Then
lstEvents.Enabled = True
btnClearEvents.Enabled = True
Caption = gl_FormTitle & " - with Event Handling"
Else
lstEvents.Enabled = False
btnClearEvents.Enabled = False
Caption = gl_FormTitle & " - without Event Handling"
End If
End Sub
Private Sub Connect()
Dim str_UserName As String
Dim str_UserID As String
Dim RFServerInfo As RFCOMAPILib.ServerInfo
' Set up the connection with RFServer
Set gl_MyFaxServer = New RFCOMAPILib.FaxServer
gl_MyFaxServer.UseNTAuthentication = False
gl_MyFaxServer.ServerName = edRFServer.Text
gl_MyFaxServer.AuthorizationUserID = edLogin.Text
gl_MyFaxServer.AuthorizationUserPassword = edPassword.Text
gl_MyFaxServer.Protocol = 0
On Error Resume Next
gl_MyFaxServer.OpenServer
If Err.Number <> 0 Then
' Exception handling when fail to connect
CleanUIElements
MsgBox Err.Description & vbNewLine & "Please enter again.", vbOKOnly, "Fail to connect to " & gl_MyFaxServer.ServerName
Else
gl_Connect = True
startTimer
' Reset UI elements for connected status
edRFServer.Enabled = False
edLogin.Enabled = False
edPassword.Enabled = False
ChkEventHandle.Enabled = False
btnConnect.Caption = "Disconnect"
lst_Users.Clear
lstEvents.Clear
' Populating the server info
Set RFServerInfo = gl_MyFaxServer.ServerInfo
lbServerName.Caption = RFServerInfo.ServerName
lbServerType.Caption = gl_MyFaxServer.Version
lbVersion.Caption = RFServerInfo.ServerVersionAsString
lbChannelNo.Caption = RFServerInfo.NumberOfLicensedChannels
lbSerialNo.Caption = RFServerInfo.SerialNumber
' Registering event handler
If (ChkEventHandle.Value) Then
Set MyFaxServerEventHandler = gl_MyFaxServer
Set rfEvents = gl_MyFaxServer.Events
rfEvents.WatchNewFaxes(gl_MyFaxServer.AuthorizationUser) = True
lbMonitoredUser.Caption = gl_MyFaxServer.AuthorizationUser & "\Main"
End If
' Populate the user list
For Each User In gl_MyFaxServer.Users
str_UserID = User.ID
str_UserName = User.UserName
lst_Users.AddItem str_UserID & vbTab & str_UserName
Next
End If
End Sub
Private Sub myTimer_Timer()
Dim strMsg As String
Dim strDay, strHour, strMin, strSec As String
Dim totalSec As Integer
totalSec = DateDiff("s", gl_startDateTime, Now)
strDay = CStr(totalSec \ 86400)
strHour = CStr((totalSec Mod 86400) \ 3600) & "h "
strMin = CStr(((totalSec Mod 86400) Mod 3600) \ 60) & "m "
strSec = CStr(((totalSec Mod 86400) Mod 3600) Mod 60) & "s "
' Optionally display day field
If strDay = "0" Then
strDay = ""
Else
strDay = strDay + "d "
End If
strMsg = " The current session has been connected for " & strDay & strHour & strMin & strSec
lbConnectTime.Caption = strMsg
End Sub
Private Sub startTimer()
myTimer.Enabled = True
gl_startDateTime = Now
End Sub
Private Sub stopTimer()
myTimer.Enabled = False
End Sub
Private Function whatFaxStatus(ByVal status As RFCOMAPILib.FaxStatusType)
Dim strFaxStatus As String
' Switch (status)
' Case fsDoneError: strFaxStatus = "fsDoneError"
' Case fsDoneOK: strFaxStatus = "fsDoneOK"
'default: strFaxStatus = status
If (status = fsDoneOK) Then
strFaxStatus = "Ok"
ElseIf (status = fsDuplicate) Then
strFaxStatus = "Duplicate"
ElseIf (status = fsError) Then
strFaxStatus = "Error"
Else
strFaxStatus = status
End If
whatFaxStatus = strFaxStatus
End Function
Private Function whatErrorCode(ByVal errCode As RFCOMAPILib.FaxErrorCodeType)
Dim strErrCode As String
If (errCode = fecNone) Then
strErrCode = "None"
ElseIf (errCode = fecBusy) Then
strErrCode = "Busy"
ElseIf (errCode = fecNoAnswer) Then
strErrCode = "NoAns"
ElseIf (errCode = fecLineProblem) Then
strErrCode = "Line"
ElseIf (errCode = fecUnknown) Then
strErrCode = "Unknown"
Else
strErrCode = errCode
End If
whatErrorCode = strErrCode
End Function
Private Function TimeStamp()
Dim currentTime, strHour, strMin
currentTime = Time
strHour = CStr(Hour(currentTime))
strMin = CStr(Minute(currentTime))
' For providing a fixed-length timestamp
If Len(strHour) = 1 Then
strHour = "0" & strHour
End If
If Len(strMin) = 1 Then
strMin = "0" & strMin
End If
TimeStamp = strHour & ":" & strMin
End Function