Edit: I'm having some weird .NET problems.. I'll get back to you
Edit 2:
Ok heres the deal, if you want your program to be able to discover new instances of the api when you close and reload Windows Live Messenger you should just have a timer that runs every 20 seconds or so and creates a new instance of the API, each time checking details such as FriendlyName, Status & Display Picture to see if there have been any changes since the last attempt to create an instance.
BUT
As I discovered today, there are some problems with this. When you close and reload messenger and your program attempts to create a new instance of the API you will receive some bogus COMException, and you won't receive it only once.. the error will be raised a number of times depending on how many events you have subscribed to in your application.
The solution to this is to NOT use the old style WithEvents method to handle the messenger API events, instead use the AddHandler/RemoveHandler functions to subscribe to the messenger events manually:
mMsgr = New MSNMessengerAPI.Messenger
AddHandler mMsgr.OnMyStatusChange, New MSNMessengerAPI.DMSNMessengerEvents_OnMyStatusChangeEventHandler(AddressOf mMsgr_OnMyStatusChange)
AddHandler mMsgr.OnMyPropertyChange, New MSNMessengerAPI.DMSNMessengerEvents_OnMyPropertyChangeEventHandler(AddressOf mMsgr_OnMyPropertyChange)
As bizarre as it sounds, if you do it this way you will not receive any bogus COMExceptions and your application can freely create new instances of the messenger API whenver it likes. Believe me.. it took me a looooong time to figure out this solution :)
Now I have one question/request for you TheSteve, would it be possible to modify this nice little library of yours so that it doesn't create new instances of WLM when you don't have WLM open? Some may like the standard functionality but because of polygamy, when I use this library in my application (which runs on windows startup) it has the tendancy to open a second instance of WLM... Which can be a pain in the ass because they both start signing in and one throws some weird "Display name could not be changed" error and then crashes.
Anyway all that aside, great job, your library fills a void which has been waiting to be filled for years :)
This post has been edited by twentytwo: 15 October 2006 - 10:56 AM