Click here to Skip to main content
Click here to Skip to main content

Creating Windows Live Messenger Add-ins

By , 21 Jun 2007
Rate this:
Please Sign up or sign in to vote.

Sample image

Introduction

We all know good old MSN and if you are a bit like me, you just love the games like tic-tac-toe and poker. Well, there are many articles that show you how to create new games -- one of them is here -- and there are many articles that show you how to extend your own application (hehehehe MINE ALL MINE !!!!!!!! HAHAHA Wink | ;-) , but did you know that you can create a plug-in for it, as well? Well, you do now Smile | :) .

The reason why most people don't know about this nice feature is because it isn't enabled by default and is intended to get some nice feedback from you: the DEVELOPERS. Now let's get started with that programming!

Background

To really understand this article, you only need to know a few things:

  • How to download MSN Messenger
  • How to use MSN Messenger
  • And how to fool around (Nah, that last one isn't really a requirement)

Getting started

If you want to begin programming your own new feature into MSN, you are going to try and test the plug-in. This will not work. If you remember what I said a few lines back, "It isn't enabled by default." To enable the feature, you must create or adapt a key in your registry: HKEY_CURRENT_USER\SOFTWARE\Microsoft\MSNMessenger\AddInFeatureEnabled must be set to 1. To turn it off, you must delete it or change its value to 0. If you are lazy and don't want to look for the key, just start up LiveMessengerRegistryAdapter.exe. It is a small program that can change the value of the key.

Now if you go and start up your MSN, you should see a new tab in your options dialog: Add-ins. This will be our main entrance into the world of pluggies (I wanted to say fairytales, but it sounded childish). This menu is used to load plug-ins, but it does not activate them. To activate a plug-in you just need to read on.

You are now ready to take on the real challenge: finding something that people can use in their MSN Messenger. I failed in that task; all you will see here are things nobody wants and no one asks for...

Create a Class Library and import a reference to the following library: C:\Program Files\MSN Messenger\MessengerClient.dll. Then create a class with the name of your add-in. Now before we go any further, there is a requirement for an add-in. That is, the assembly name must have a name in the Namespace.ClassName format. This must be the full name of the class that implements the IMessengerAddIn interface. In VS 2005, this is also the project name. This is all because the programmers of the MessengerClient were too lazy to do reflection on the DLL. Instead, they used the DLL name to determine which class inside the assembly to instantiate.

If the name does not match the class name that uses the IMessengerAddIn interface, then you will get a large MessageBox with the message that tells you that it failed to load in the class. This is the tricky part because the hard part is over from the minute you can load the library in your Live Messenger. So, I recommend that you first implement the interface and then test the compiled DLL in your client.

The only real bugger in this feature is that you have to shut down MSN Messenger each and every time you want to rebuild the application.

Using the code

As always, most of my explaining is located inside the code files. However, I will show you the best parts of my add-in. I love this part, as you scan all incoming messages for "dirty" words and then react to the dirty words. It would be easy for you to use a database that is on the other side of the planet and insert all the words in the database...

void Client_IncomingTextMessage(object sender, IncomingTextMessageEventArgs e)
{
    // Checkout the incoming textmessage...
    if (e.TextMessage.Contains("porn") ||
    e.TextMessage.Contains("pron") ||
    e.TextMessage.Contains("porno"))
    {
        String caption = "WARNING";

        StringBuilder textMessage = new StringBuilder();
        textMessage.Append("MESSAGE TO ALL PEOPLE AROUND:\n");
        textMessage.Append(e.UserFrom.Email);
        textMessage.Append(" is sending PORN to this nice little nerd!!!");

        // Alert every person that is standing in the neighbourhood.
        System.Windows.Forms.MessageBox.Show(textMessage.ToString(), caption,
        System.Windows.Forms.MessageBoxButtons.OK,
        System.Windows.Forms.MessageBoxIcon.Exclamation);

        // And make this a noisy message :-)
        for (int i = 0; i < 10; i++)
        {
             System.Media.SystemSounds.Beep.Play();
             System.Media.SystemSounds.Exclamation.Play();
        }

        // And finally warn the other user not to 
        // send porn to this little nerd.
        // Just show him a red text message :-).
        // You could also send him a normal text message using 
        // "Client.SendTextMessage(text, userTo);"
        Client.SendActionMessage(Client.LocalUser.FriendlyName + 
            " is not allowed to receive porn.", e.UserFrom);
    }
}

Well, I really should encourage you to view the code file. It is more comment than code, so don't worry... And I hope this article will get you all started programming features for MSN Live.

Warning

I just went crazy when my plug-in did not work while loaded. The plug-in will only work when you actually activate it manually. This is, of course, after you load the plug-in into the Add-in tab. See the first picture for the Add-in tab.

Sample image

Points of interest

I never knew that you could bug people with a plug-in on MSN. And the people don't know that they can shut this add-in feature off... Smile | :) All that because I don't tell them. Muahahaha, I AM SO EVIL.

History

  • 18 January, 2007 -- Original version posted
  • 6 April, 2007 -- First update
  • 21 June, 2007 -- Article edited and moved to the main CodeProject.com article base

License

This article, along with any associated source code and files, is licensed under The BSD License

About the Author

No Biography provided

Comments and Discussions

 
GeneralMy vote of 5 PinmemberMember 16167115-Dec-11 22:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140421.2 | Last Updated 21 Jun 2007
Article Copyright 2007 by Filip van der Meeren
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid