AIMCC C# Plugin Tutorial


Lesson 2 : Plugging into AIMCC

To get your new object plugged into AIMCC, you need to implement the IAccPlugin interface, and register your plugin with AIMCC.

Before we can implement IAccPlugin, we first need to add a project reference to AccCoreLib. To do this, select Project -> AddReference. You will see a dialog with three tabs; click the COM tab to list all the available COM objects.

Select AccCore 1.0 Type Library from the list at the top, and then click the Select button. (If AccCore is not present in the list, it means that you did not run AIM 6.x or AIM Lite prior to creating this project.) Once you have selected AccCore, it will show up in the Selected Component list at the bottom. Click OK to close the dialog. You will see AccCoreLib is now included in the list of references for your project.

To make using AIMCC easier, add a using declaration for AccCoreLib to your code:

using System;
using AccCoreLib;

namespace MyPlugin

. . .
     

Then, make your class inherit from IAccPlugin. Simply add this code

. . .

    public class Class1 : IAccPlugin

. . .

You will get a tooltip popup instructing you to hit TAB to implement the IAccPlugin members. Do this, and the following code will have been added for you:

. . .

    public class Class1 : IAccPlugin
    {
          public Class1()
          {
               //
               // TODO: Add constructor logic here
               //

          }
          #region IAccPlugin Members

          public void Init(AccSession session, IAccPluginInfo pluginInfo)
          {
              // TODO: Add Class1.Init implementation
          }

          public void Shutdown()
          {
              // TODO: Add Class1.Shutdown implementation
          }    
       
          #endregion

     }

. . .

You have now implemented IAccPlugin for your plugin. Now all we have to do is to get the plugin registered with AIMCC. In order to do this, we need to get an "AIM Plugin Development Key", otherwise known as a UUID, from the AIM Developer site and add that key to the top of the class. This key is simply another UUID that is known to the AIM servers, and so when you replace the existing UUID with it, it will not look much different.  Next, we need to add methods to write the necessary plugin registration information to the registry when the object is registered for COM interop. We make use of the COM register and unregister function attributes to do this:

using System;
using System.Runtime.InteropServices;
using Microsoft.Win32;

using AccCoreLib;

namespace MyPlugin
{    
    [GuidAttribute("your-development-key-here")]

    public class Class1 : IAccPlugin
    {
. . .

        #region Plugin Registration
        [ComRegisterFunctionAttribute]
        public static void RegisterFunction(Type t)
        {
            RegistryKey key = Registry.LocalMachine.CreateSubKey(PluginKeyName(t));
            key.SetValue("Name", t.Name); 
        } 
        [ComUnregisterFunctionAttribute]
        public static void UnregisterFunction(Type t)
        {
            Registry.LocalMachine.DeleteSubKey(PluginKeyName(t));
        } 
        private static string PluginKeyName(Type t)
        {
            return "Software\\America Online\\AIM\\Plugins\\" + 
                '{' + t.GUID.ToString() + '}';
        } 
        #endregion
    }
}

That's it! You can now build your project, it will self-register, and the next time you run an AIMCC application, your plugin will be loaded!

Next Lesson | Back to Table of Contents


Questions? Visit http://developer.aim.com/
Last updated: 03/17/2007