S SiWeiLiuLang Unregistered / Unconfirmed GUEST, unregistred user! 2006-01-23 #2 给你提供点信息,帮你顶起<br>关于MSN 6的一些API介绍 <br>2004年6月11日 13:10 <br>了解这方面内容的起因是早上有位朋友让我看一段关于MSN开发程序,现在无法运行,我打开工程发现是针对4.7编写的,而他的计算机安装的6,2,因为我也用6.2所以我在VB中查看了一下,发现是缺少Messenger Type Library。但是多了Messenger API Type Library,可能是做为Messenger Type Library的替代,但是发现它的功能不如以前的Messenger Type Library 全面,起码我现在就发现它不能修改本地的MyFriendlyName,不明白为什么把它弄成只读的,MyStatus是可写。<br><br>下面简单用VB距离说明怎么调用它:<br><br>首先当然是引用对象Messenger API Type Library了。<br><br>然后声明一个对象MessengerAPI.Messenger<br>Private WithEvents oMSN As MessengerAPI.Messenger<br><br>我们需要的东西都在这里边,简单介绍几个:<br>MyContacts:IMessengerContacts 对象<br>MyFriendlyName: 当前的昵称<br>MyGroups: IMessengerGroupss对象<br>MyPhoneNumber:返回电话号码<br>MyProperty:现在没有使用<br>MyServiceId :返回Service id应该是{9b017612-c9f1-11d2-8d9f-0000f875c541}]<br>MyServiceName:返回Service name应该是 .NET Messenger Service<br>MySigninName:返回当前的签名,eMail地址<br>MyStatus:返回当前状态,MISTATUS枚举值<br>其实本地属性和通过PrimaryService得到的一样<br><br>做几个简单的演示:<br>首先是登陆演示,使用MessengerAPI.Messenger的 SignIn 或者AutoSignin方法:<br>Public Sub SignIn(ByVal bAuto As Boolean, Optional ByVal sSignInName As String, Optional ByVal sPassword As String)<br>On Error GoTo ErrorHandle<br> If bAuto = True Then<br> oMSN.AutoSignin<br> Else<br>ManualSignIn:<br> oMSN.SignIn 0, sSignInName, sPassword<br> End If<br><br> Exit Sub<br>ErrorHandle:<br>Dim MConstants As MSGRConstants<br> MConstants = err.Number<br> If MConstants = MSGR_E_FAIL Then<br> GoTo ManualSignIn<br> ElseIf MConstants = MSGR_E_ALREADY_LOGGED_ON Then<br> '已经登陆<br> End If<br>End Sub<br><br>获取全部用户列表:<br>通过Messenger的MyContacts对象(它是只读的)<br>它其实就是一个IMessengerContacts对象,而IMessengerContacts类又是IMessengerContact类的一个集合,在IMessengerContact中保存联系人信息。<br>因此可以这样遍历联系人。<br>Dim oContacts As IMessengerContacts<br>Dim oContact As IMessengerContact<br>Dim iCount As Integer<br>Dim i As Long<br>Set oContacts = oMSN.MyContacts<br>iCount = oContacts.Count<br>For i = 0 To iCount - 1<br> Set oContact = MsgrContacts.Item<br> List1.AddItem MsgrContact.FriendlyName & vbTab & "(" & getStatusDesc(MsgrContact.Status) & ""<br>Next<br><br>getStatusDesc函数用来返回状态文本描述:<br>Private Function getStatusDesc(eStatus As MISTATUS) As String<br> Select Case eStatus<br> Case MISTATUS_AWAY<br> getStatusDesc = "走开了"<br> Case MISTATUS_BE_RIGHT_BACK<br> getStatusDesc = "马上回来"<br> Case MISTATUS_BUSY<br> getStatusDesc = "在忙碌"<br> Case MISTATUS_IDLE<br> getStatusDesc = "在发呆"<br> Case MISTATUS_INVISIBLE<br> getStatusDesc = "隐身"<br> Case MISTATUS_LOCAL_CONNECTING_TO_SERVER<br> getStatusDesc = "正在链接服务器"<br> Case MISTATUS_LOCAL_DISCONNECTING_FROM_SERVER<br> getStatusDesc = "从服务器断开"<br> Case MISTATUS_LOCAL_FINDING_SERVER<br> getStatusDesc = "正在搜索服务器"<br> Case MISTATUS_LOCAL_SYNCHRONIZING_WITH_SERVER<br> getStatusDesc = "正在和服务器同步"<br> Case MISTATUS_OFFLINE<br> getStatusDesc = "离线"<br> Case MISTATUS_ON_THE_PHONE<br> getStatusDesc = "在接电话"<br> Case MISTATUS_ONLINE<br> getStatusDesc = "在线"<br> Case MISTATUS_OUT_TO_LUNCH<br> getStatusDesc = "外出就餐"<br> Case MISTATUS_UNKNOWN<br> getStatusDesc = "未知"<br> End Select<br> <br>End Function<br><br>获取组列表:<br>方法同获取联系人,只是换了一下对象.<br>Dim oGroups As IMessengerGroups<br>Dim oGroup As IMessengerGroup<br> Set oGroups = oMSN.MyGroups<br> For Each oGroup In oGroups<br> List1.AddItem oGroup.Name<br> Next<br> <br> 下面就是将组和用户关联起来:<br> 明白上面的方法,这个很容易实现,IMessengerGroup类的对象中含有IMessengerContact类对象的集合。<br> Dim oGroups As IMessengerGroups<br>Dim oGroup As IMessengerGroup<br>Dim oContacts As IMessengerContacts<br>Dim oContact As IMessengerContact<br> Set oGroups = oMSN.MyGroups<br> For Each oGroup In oGroups<br> Set oContacts = oGroup.Contacts<br> For Each oContact In oContacts<br> List1.AddItem oGroup.Name & " " & oContact.SigninName<br> Next<br> Next <br> 在介绍一下服务:<br> 也是用样道理:<br> Dim oServices As IMessengerServices<br>Dim oService As IMessengerService<br> Set oServices = oMSN.Services<br> Set oService = oServices.PrimaryService<br> MsgBox oService.MyFriendlyName & getStatusDesc(oService.MyStatus) & oService.MySigninName & oService.ServiceId & oService.ServiceName<br><br>我现在怎么觉得PrimaryService的意义不大,IMessengerServices中就一个PrimaryService可用,还是只读的。<br>当然各个对象可能还有一些相应的方法就不多介绍,我介绍的这些通过对象浏览器就可以看明白,其中还有对象或成员我现在还没学会使用,现在只是大致了解一下,我希望看到这篇文章的人也有了一点初步了解。
给你提供点信息,帮你顶起<br>关于MSN 6的一些API介绍 <br>2004年6月11日 13:10 <br>了解这方面内容的起因是早上有位朋友让我看一段关于MSN开发程序,现在无法运行,我打开工程发现是针对4.7编写的,而他的计算机安装的6,2,因为我也用6.2所以我在VB中查看了一下,发现是缺少Messenger Type Library。但是多了Messenger API Type Library,可能是做为Messenger Type Library的替代,但是发现它的功能不如以前的Messenger Type Library 全面,起码我现在就发现它不能修改本地的MyFriendlyName,不明白为什么把它弄成只读的,MyStatus是可写。<br><br>下面简单用VB距离说明怎么调用它:<br><br>首先当然是引用对象Messenger API Type Library了。<br><br>然后声明一个对象MessengerAPI.Messenger<br>Private WithEvents oMSN As MessengerAPI.Messenger<br><br>我们需要的东西都在这里边,简单介绍几个:<br>MyContacts:IMessengerContacts 对象<br>MyFriendlyName: 当前的昵称<br>MyGroups: IMessengerGroupss对象<br>MyPhoneNumber:返回电话号码<br>MyProperty:现在没有使用<br>MyServiceId :返回Service id应该是{9b017612-c9f1-11d2-8d9f-0000f875c541}]<br>MyServiceName:返回Service name应该是 .NET Messenger Service<br>MySigninName:返回当前的签名,eMail地址<br>MyStatus:返回当前状态,MISTATUS枚举值<br>其实本地属性和通过PrimaryService得到的一样<br><br>做几个简单的演示:<br>首先是登陆演示,使用MessengerAPI.Messenger的 SignIn 或者AutoSignin方法:<br>Public Sub SignIn(ByVal bAuto As Boolean, Optional ByVal sSignInName As String, Optional ByVal sPassword As String)<br>On Error GoTo ErrorHandle<br> If bAuto = True Then<br> oMSN.AutoSignin<br> Else<br>ManualSignIn:<br> oMSN.SignIn 0, sSignInName, sPassword<br> End If<br><br> Exit Sub<br>ErrorHandle:<br>Dim MConstants As MSGRConstants<br> MConstants = err.Number<br> If MConstants = MSGR_E_FAIL Then<br> GoTo ManualSignIn<br> ElseIf MConstants = MSGR_E_ALREADY_LOGGED_ON Then<br> '已经登陆<br> End If<br>End Sub<br><br>获取全部用户列表:<br>通过Messenger的MyContacts对象(它是只读的)<br>它其实就是一个IMessengerContacts对象,而IMessengerContacts类又是IMessengerContact类的一个集合,在IMessengerContact中保存联系人信息。<br>因此可以这样遍历联系人。<br>Dim oContacts As IMessengerContacts<br>Dim oContact As IMessengerContact<br>Dim iCount As Integer<br>Dim i As Long<br>Set oContacts = oMSN.MyContacts<br>iCount = oContacts.Count<br>For i = 0 To iCount - 1<br> Set oContact = MsgrContacts.Item<br> List1.AddItem MsgrContact.FriendlyName & vbTab & "(" & getStatusDesc(MsgrContact.Status) & ""<br>Next<br><br>getStatusDesc函数用来返回状态文本描述:<br>Private Function getStatusDesc(eStatus As MISTATUS) As String<br> Select Case eStatus<br> Case MISTATUS_AWAY<br> getStatusDesc = "走开了"<br> Case MISTATUS_BE_RIGHT_BACK<br> getStatusDesc = "马上回来"<br> Case MISTATUS_BUSY<br> getStatusDesc = "在忙碌"<br> Case MISTATUS_IDLE<br> getStatusDesc = "在发呆"<br> Case MISTATUS_INVISIBLE<br> getStatusDesc = "隐身"<br> Case MISTATUS_LOCAL_CONNECTING_TO_SERVER<br> getStatusDesc = "正在链接服务器"<br> Case MISTATUS_LOCAL_DISCONNECTING_FROM_SERVER<br> getStatusDesc = "从服务器断开"<br> Case MISTATUS_LOCAL_FINDING_SERVER<br> getStatusDesc = "正在搜索服务器"<br> Case MISTATUS_LOCAL_SYNCHRONIZING_WITH_SERVER<br> getStatusDesc = "正在和服务器同步"<br> Case MISTATUS_OFFLINE<br> getStatusDesc = "离线"<br> Case MISTATUS_ON_THE_PHONE<br> getStatusDesc = "在接电话"<br> Case MISTATUS_ONLINE<br> getStatusDesc = "在线"<br> Case MISTATUS_OUT_TO_LUNCH<br> getStatusDesc = "外出就餐"<br> Case MISTATUS_UNKNOWN<br> getStatusDesc = "未知"<br> End Select<br> <br>End Function<br><br>获取组列表:<br>方法同获取联系人,只是换了一下对象.<br>Dim oGroups As IMessengerGroups<br>Dim oGroup As IMessengerGroup<br> Set oGroups = oMSN.MyGroups<br> For Each oGroup In oGroups<br> List1.AddItem oGroup.Name<br> Next<br> <br> 下面就是将组和用户关联起来:<br> 明白上面的方法,这个很容易实现,IMessengerGroup类的对象中含有IMessengerContact类对象的集合。<br> Dim oGroups As IMessengerGroups<br>Dim oGroup As IMessengerGroup<br>Dim oContacts As IMessengerContacts<br>Dim oContact As IMessengerContact<br> Set oGroups = oMSN.MyGroups<br> For Each oGroup In oGroups<br> Set oContacts = oGroup.Contacts<br> For Each oContact In oContacts<br> List1.AddItem oGroup.Name & " " & oContact.SigninName<br> Next<br> Next <br> 在介绍一下服务:<br> 也是用样道理:<br> Dim oServices As IMessengerServices<br>Dim oService As IMessengerService<br> Set oServices = oMSN.Services<br> Set oService = oServices.PrimaryService<br> MsgBox oService.MyFriendlyName & getStatusDesc(oService.MyStatus) & oService.MySigninName & oService.ServiceId & oService.ServiceName<br><br>我现在怎么觉得PrimaryService的意义不大,IMessengerServices中就一个PrimaryService可用,还是只读的。<br>当然各个对象可能还有一些相应的方法就不多介绍,我介绍的这些通过对象浏览器就可以看明白,其中还有对象或成员我现在还没学会使用,现在只是大致了解一下,我希望看到这篇文章的人也有了一点初步了解。
D dongejkle Unregistered / Unconfirmed GUEST, unregistred user! 2006-01-28 #4 帮顶! <br><br>http://www.source520.com <br><br>站长开发推广同盟 站长朋友的终极驿站 <br>同时拥有海量源码电子经典书籍下载 <br><br>http://www.source520.com/search/search.asp <br><br>"编程.站长"论坛搜索引擎-----为中国站长注入动力!
帮顶! <br><br>http://www.source520.com <br><br>站长开发推广同盟 站长朋友的终极驿站 <br>同时拥有海量源码电子经典书籍下载 <br><br>http://www.source520.com/search/search.asp <br><br>"编程.站长"论坛搜索引擎-----为中国站长注入动力!