Call MSN 6.2 API function in VB
The reason to understand this is that a friend of mine in the morning Let me read a section on MSN Development Program, now unable to run, I opened the project found to be written for 4.7, while his computer installed 6, 2, because I also used 6.2 so I looked in VB, found that the messenger Type is missing Library. But with the Messenger API type library, it might be an alternative to the Messenger type library, but it's not as comprehensive as the previous Messenger type library, At least I now find that it can not modify the local myfriendlyname, do not understand why make it read-only, Mystatus is writable.
Here is a simple VB distance to explain how to call it:
The first of course is referencing the object Messenger API Type library.
Then declare an object Messengerapi.messenger:
Private WithEvents Omsn as Messengerapi.messenger
The things we need are all here, a brief introduction to several:
Mycontacts:imessengercontacts objects
Myfriendlyname: The current nickname
MYGROUPS:IMESSENGERGROUPSS objects
Myphonenumber: Return phone number
MyProperty: No use now
Myserviceid: Return service ID should be {9b017612-c9f1-11d2-8d9f-0000f875c541}]
myServiceName: Return service name should be. NET Messenger Service
Mysigninname: Return the current signature, email address
Mystatus: Returns the current state, Mistatus the enumeration value
In fact, the local properties are the same as those obtained through Primaryservice
Do a few simple demos:
The first is a login demo, using the Messengerapi.messenger signin or Autosignin method:
Public Sub signin (ByVal bauto as Boolean, Optional ByVal ssigninname As String, Optional ByVal to Spassword as String) on Error GoTo errorhandle If bauto = True Then omsn.autosignin Else ManualSignIn:oMSN.SignIn 0, Ssigninname, spasswo Rd 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 ' has landed E nd If End Sub
Gets the list of all users:
through Messenger's MyContacts object (it is read-only)
It's actually a Imessengercontacts object, The Imessengercontacts class is also a collection of imessengercontact classes that hold contact information in Imessengercontact.
So you can traverse contacts this way.
Dim ocontacts As Imessengercontacts Dim ocontact As Imessengercontact Dim icount As Integer Dim i as Long Set Ocon Tacts = Omsn.mycontacts icount = ocontacts.count for i = 0 to iCount-1 Set ocontact = Msgrcontacts.item List1.AddItem Msgrcontact.friendlyname & VbTab & ("& Getstatusdesc (Msgrcontact.status) &") "Next
The
Getstatusdesc function is used to return a status text description:
Private function Getstatusdesc (estatus as Mistatus) as String Select case Estatus Case Mistatus_away Getstatusdesc = "Go Away" case mistatus_be_right_back Getstatusdesc = "Right back" case mistatus_busy Getstatusdesc = "in busy" case mistatus_idle Getstatusdesc = "In a daze" case mistatus_invisible Getstatusdesc = "Stealth" Case Mistatus_local_connecting_to_server Getstatusdesc = "Being linked server" case Mistatus_local_disconnecting_from_server Getstatusdesc = "Disconnect from server" case mistatus_local_finding_server GETSTATUSDESC = "Searching server" case Mistatus_local_synchron Izing_with_server Getstatusdesc = "Synchronizing with server" case mistatus_offline Getstatusdesc = "Offline" Case Mistatus_on_the_pho NE Getstatusdesc = "In answer phone" case mistatus_online Getstatusdesc = "Online" Case Mistatus_out_to_lunch Getstatusdesc = "Dine Out" case Mistatus_unknown Getstatusdesc = "Unknown" End Select-end Function
Get group list:
method to get the contact person, just change the object.
Dim ogroups As Imessengergroups Dim ogroup As Imessengergroup Set ogroups = omsn.mygroups for each ogroup in Ogroups List 1.AddItem Ogroup.name Next
The following is the association of groups and users:
Understand the above method, this is easy to implement, the Imessengergroup class object contains a collection of Imessengercontact class objects.
Dim ogroups As Imessengergroups Dim ogroup As Imessengergroup Dim ocontacts As Imessengercontacts Dim ocontact As IMesseng Ercontact Set ogroups = omsn.mygroups for all ogroup in ogroups Set ocontacts = ogroup.contacts for each ocontact in OC Ontacts list1.additem Ogroup.name & "" & Ocontact.signinname Next Next
In the introduction of services:
is also the use of the kind of truth:
Dim oservices As Imessengerservices Dim oservice As Imessengerservice Set oservices = Omsn.services Set oservice = OServic Es. Primaryservice MsgBox Oservice.myfriendlyname & Getstatusdesc (oservice.mystatus) & Oservice.mysigninname & Oservice.serviceid & Oservice.servicename
How do I feel now that primaryservice is not very meaningful, imessengerservices is a primaryservice available, or read-only.
Of course, the individual objects may have some corresponding methods that are not described in more detail, I introduced these through the Object Browser can be seen, and there are objects or members I have not learned to use, now just a general understanding, I hope that the people who read this article also have a little preliminary understanding.