我要写一个监控的程序,需要向MSN用户发消息,请问各位大侠怎么才能实现啊。
如果方便的话提供个例子,感激不尽
API我已经调用了,但总显示“实时错误 '91' 对象变量或WITH块变量未定义”
代码如下:
Private WithEvents oMSN As MessengerAPI.Messenger
Public Sub SignIn(ByVal bAuto As Boolean, Optional ByVal sSignInName As String, Optional ByVal sPassword As String)
On Error GoTo ErrorHandle
If bAuto = True Then
oMSN.AutoSignin
Else
ManualSignIn:
oMSN.SignIn 0, sSignInName, sPassword
End If
Exit Sub
ErrorHandle:
Dim MConstants As MSGRConstants
MConstants = Err.Number
If MConstants = MSGR_E_FAIL Then
GoTo ManualSignIn
ElseIf MConstants = MSGR_E_ALREADY_LOGGED_ON Then
'已经登陆
End If
End Sub
Private Function getStatusDesc(eStatus As MISTATUS) As String
Select Case eStatus
Case MISTATUS_AWAY
getStatusDesc = "走开了"
Case MISTATUS_BE_RIGHT_BACK
getStatusDesc = "马上回来"
Case MISTATUS_BUSY
getStatusDesc = "在忙碌"
Case MISTATUS_IDLE
getStatusDesc = "在发呆"
Case MISTATUS_INVISIBLE
getStatusDesc = "隐身"
Case MISTATUS_LOCAL_CONNECTING_TO_SERVER
getStatusDesc = "正在链接服务器"
Case MISTATUS_LOCAL_DISCONNECTING_FROM_SERVER
getStatusDesc = "从服务器断开"
Case MISTATUS_LOCAL_FINDING_SERVER
getStatusDesc = "正在搜索服务器"
Case MISTATUS_LOCAL_SYNCHRONIZING_WITH_SERVER
getStatusDesc = "正在和服务器同步"
Case MISTATUS_OFFLINE
getStatusDesc = "离线"
Case MISTATUS_ON_THE_PHONE
getStatusDesc = "在接电话"
Case MISTATUS_ONLINE
getStatusDesc = "在线"
Case MISTATUS_OUT_TO_LUNCH
getStatusDesc = "外出就餐"
Case MISTATUS_UNKNOWN
getStatusDesc = "未知"
End Select
End Function
Private Sub Command1_Click()
Dim oGroups As IMessengerGroups
Dim oGroup As IMessengerGroup
Set oGroups = oMSN.MyGroups
For Each oGroup In oGroups
List1.AddItem oGroup.Name
Next
End Sub
Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
End Sub