Plug-in Development for Google Desktop
A Wikibookian believes this page should be split into smaller pages with a narrower subtopic. You can help by splitting this big page into smaller ones. Please make sure to follow the naming policy. Dividing books into smaller sections can provide more focus and allow each one to do one thing well, which benefits everyone. |
Getting Started
editThings you need
editHow to get started
editYou need to create a COM object.
What is a COM object and why do I need to create it?
editGD uses COM objects as plugins. Actually these are like ActiveX components. They are meant to be reusable.
How to create a COM object
editIn Visual Studio, create a C# Class Library.
Preliminary code for the Class Library project
editYou should implement two (2) methods:
static void ComRegisterFunctionAttribute(Type t) { include initialization code here }
This function is called whenever you register your COM object to the system. You can put initialization code here, like code that will register our plugin to GD (Details later).
static void ComUnregisterFunctionAttribute(Type t) { }
This function is called whenever you unregister your COM object.
You should have the following statement:
using System.Runtime.InteropServices;
What kind of files are created when I compile my Class Library project?
editAfter building your Class Library project, Visual Studio will generate the following file types in your output folder: .dll and .tlb
The .dll file generated is actually a COM object that we need to register to the system.
How to load/register a COM object
editUse: regasm [dllfile] /tlb
Regasm.exe is located in your .Net Framework bin folder.
What method/code is first executed after I load a COM object?
editThe system makes a call to ComRegisterFunctionAttribute so it is necessary that you implement this method. It is here where we put our initialization, like a block of code that will register our plugin to GD.
Registering the plugin to GD
edittry { GoogleDesktopRegistrarClass registrar = new GoogleDesktopRegistrarClass(); // Start component registration by specifying our attributes object[] descriptions = { "Title", pluginName, "Description", pluginName, "Icon", "" }; registrar.StartComponentRegistration(controlGuid, descriptions); IGoogleDesktopRegisterDisplayPlugin displayRegistration = (IGoogleDesktopRegisterDisplayPlugin) registrar.GetRegistrationInterface("GoogleDesktop.DisplayPluginRegistration"); displayRegistration.RegisterPlugin(controlGuid, false); // Done with component registration. registrar.FinishComponentRegistration(); } catch (Exception e) { MessageBox.Show("Exception thrown during registration. Description=" + e.Message); }
What happens when my plugin is registered in GD?
editYour plugin will appear in the add/remove panel list in Google Desktop.