Plug-in Development for Google Desktop
Contents
- 1 Getting Started
- 1.1 Things you need
- 1.2 How to get started
- 1.3 What is a COM object and why do I need to create it?
- 1.4 How to create a COM object
- 1.5 Preliminary code for the Class Library project
- 1.6 What kind of files are created when I compile my Class Library project?
- 1.7 How to load/register a COM object
- 1.8 What method/code is first executed after I load a COM object?
- 1.9 Registering the plugin to GD
- 1.10 What happens when my plugin is registered in GD?
- 2 Advanced Topics
Getting Started[edit]
Things you need[edit]
How to get started[edit]
You need to create a COM object
What is a COM object and why do I need to create it?[edit]
GD uses COM objects as plugins. Actually these are like ActiveX components. They are meant to be reusable.
How to create a COM object[edit]
In Visual Studio, create a C# Class Library.
Preliminary code for the Class Library project[edit]
You 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?[edit]
After 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[edit]
Use: 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?[edit]
The 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[edit]
try { 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?[edit]
Your plugin will appear in the add/remove panel list in Google Desktop.