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 |
Dim oContacts As IMessengerContacts Dim oContact As IMessengerContact Dim iCount As Integer Dim i As Long Set oContacts = oMSN.MyContacts iCount = oContacts.Count For i = 0 To iCount - 1 Set oContact = MsgrContacts.Item List1.AddItem MsgrContact.FriendlyName & vbTab & "(" & getStatusDesc(MsgrContact.Status) & ")" Next |
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 |
Dim oGroups As IMessengerGroups Dim oGroup As IMessengerGroup Set oGroups = oMSN.MyGroups For Each oGroup In oGroups List1.AddItem oGroup.Name Next |
Dim oGroups As IMessengerGroups Dim oGroup As IMessengerGroup Dim oContacts As IMessengerContacts Dim oContact As IMessengerContact Set oGroups = oMSN.MyGroups For Each oGroup In oGroups Set oContacts = oGroup.Contacts For Each oContact In oContacts List1.AddItem oGroup.Name & " " & oContact.SigninName Next Next |
Dim oServices As IMessengerServices Dim oService As IMessengerService Set oServices = oMSN.Services Set oService = oServices.PrimaryService MsgBox oService.MyFriendlyName & getStatusDesc(oService.MyStatus) & oService.MySigninName & oService.ServiceId & oService.ServiceName |