To implement Custom Actions and integrate your application with Google Desktop you will need, in addition to the information in this document:
Sufficient access to write a plug-in for your application and an installer for it.
Programming knowledge of the Microsoft Windows Component Object Model (COM).
The Action API consists of a COM interface, which must be exposed by plug-ins wishing to implement custom actions.
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[GuidAttribute("E5A04D23-6921-4ef6-B19B-6C6AA89A46AA")]
public interface IGoogleDesktopCustomAction
{
[DispId(1)]
void QueryInterest(
[In] Guid location,
[In] Guid action,
[In, MarshalAs(UnmanagedType.BStr)] string query_string,
[In, MarshalAs(UnmanagedType.IUnknown)] object item,
[In, Out, MarshalAs(UnmanagedType.BStr)] ref stringactionTitle,
[Out, MarshalAs(UnmanagedType.BStr)] out string actionCookie,
[Out] out ActionHandling handling);
[DispId(2)]
void HandleAction(
[In] Guid location,
[In] Guid action,
[In, MarshalAs(UnmanagedType.BStr)] string query_string,
[In, MarshalAs(UnmanagedType.IUnknown)] object item,
[In, MarshalAs(UnmanagedType.BStr)] string action_cookie);
}
* This source code was highlighted with Source Code Highlighter.
The following sample demonstrates how a component can implement the methods on the IGoogleDesktopCustomAction interface.
QueryInterest is invoked when search results are displayed in browser and HandleAction is invoked when you are opening specific item of search result.
[ComVisible(true)]
[GuidAttribute("YOU-GUID")]
public class SearchActions : IGoogleDesktopCustomAction
{
#region IGoogleDesktopCustomAction Members
public void HandleAction(Guid location, Guid action, stringquery, object item, string actionCookie)
{
try
{
string uri = ((IGoogleDesktopNotifyEvent)item).GetProperty("uri").ToString();
System.Diagnostics.Process.Start(uri);
}
catch (COMException ex)
{ }
}
public void QueryInterest(Guid location, Guid action, stringquery, object item, ref string actionTitle, out stringactionCookie, out ActionHandling handling)
{
string extension = uri.Substring(uri.LastIndexOf('.') + 1);
if (extension == "txt")
handling = ActionHandling.ACTION_HANDLING_OVERRIDE;
else
handling = ActionHandling.ACTION_HANDLING_DEFAULT;
}
}
* This source code was highlighted with Source Code Highlighter.