Click here to Skip to main content
15,867,756 members
Articles / Programming Languages / C#
Article

Creating Windows Live Messenger Add-ins

Rate me:
Please Sign up or sign in to vote.
4.81/5 (34 votes)
21 Jun 2007BSD4 min read 192.4K   604   122   70
An article on creating MSN 8 plug-ins

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 ;-), but did you know that you can create a plug-in for it, as well? Well, you do now :-).

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...

C#
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... :-) 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


Written By
Belgium Belgium
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 5 Pin
Member 16167115-Dec-11 22:49
Member 16167115-Dec-11 22:49 
Generalbad word filter to protect my kids. with [***********] 's Pin
ZUPERKOOL7-Feb-10 7:30
ZUPERKOOL7-Feb-10 7:30 
GeneralRe: bad word filter to protect my kids. with [***********] 's Pin
Filip van der Meeren7-Feb-10 10:34
Filip van der Meeren7-Feb-10 10:34 
QuestionNo MessengerClient.dll file for WLM 2009? Pin
Onur Guzel29-Jan-10 4:50
Onur Guzel29-Jan-10 4:50 
AnswerRe: No MessengerClient.dll file for WLM 2009? Pin
Filip van der Meeren30-Jan-10 1:20
Filip van der Meeren30-Jan-10 1:20 
GeneralRe: No MessengerClient.dll file for WLM 2009? Pin
Onur Guzel30-Jan-10 7:07
Onur Guzel30-Jan-10 7:07 
GeneralRe: No MessengerClient.dll file for WLM 2009? Pin
Member 468002625-Jul-10 22:47
Member 468002625-Jul-10 22:47 
GeneralWindows LIVE messenger Pin
NaNg1524115-May-09 5:10
NaNg1524115-May-09 5:10 
QuestionRe: Windows LIVE messenger Pin
Josh Powers20-May-09 13:32
Josh Powers20-May-09 13:32 
JokeRe: Windows LIVE messenger Pin
Filip van der Meeren21-May-09 9:59
Filip van der Meeren21-May-09 9:59 
GeneralGreat article, sourcecode has a very small bug Pin
Ray Guan16-Nov-08 20:10
Ray Guan16-Nov-08 20:10 
GeneralRe: Great article, sourcecode has a very small bug Pin
Filip van der Meeren16-Nov-08 21:56
Filip van der Meeren16-Nov-08 21:56 
GeneralThanks for sharing! Pin
MarkB77731-May-08 23:18
MarkB77731-May-08 23:18 
GeneralGrayed Out Pin
sabrown10023-Dec-07 12:45
sabrown10023-Dec-07 12:45 
GeneralGrayed Out Pin
sabrown10023-Dec-07 12:44
sabrown10023-Dec-07 12:44 
QuestionStatusChangedEvent Pin
plextoR5-Jul-07 8:12
plextoR5-Jul-07 8:12 
QuestionWhat about Installer? Pin
Sameers Javed30-Jun-07 15:47
Sameers Javed30-Jun-07 15:47 
AnswerRe: What about Installer? Pin
Filip van der Meeren30-Jun-07 21:35
Filip van der Meeren30-Jun-07 21:35 
GeneralRe: What about Installer? Pin
Sameers Javed1-Jul-07 5:21
Sameers Javed1-Jul-07 5:21 
GeneralRe: What about Installer? Pin
Filip van der Meeren1-Jul-07 7:52
Filip van der Meeren1-Jul-07 7:52 
GeneralRe: What about Installer? Pin
sabrown1008-Dec-07 11:48
sabrown1008-Dec-07 11:48 
QuestionCan I put a timer in the addin ?? Pin
Jason Law28-Jun-07 19:48
Jason Law28-Jun-07 19:48 
AnswerRe: Can I put a timer in the addin ?? Pin
Filip van der Meeren29-Jun-07 1:38
Filip van der Meeren29-Jun-07 1:38 
Generalwhether the plug can send html ? [modified] Pin
flyingchen28-Jun-07 16:46
flyingchen28-Jun-07 16:46 
GeneralRe: whether the plug can send html ? Pin
Filip van der Meeren29-Jun-07 1:43
Filip van der Meeren29-Jun-07 1:43 

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

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