views:

196

answers:

2

Hi,

I've got a .NET 2.0 Windows desktop application (time-sheets) which i develop and wanted to add a Gadget interface to it (so that app runs hidden and is controlled via the gadget).

What is the easiest way to get my gadget to communicate to my app?

An idea that i had was to have a built-in web server inside the app, and the gadget controls communicates with the app using ajax. However i'm hoping there's a simpler solution.

A: 

You didn't specify what technology the gadget and app were written with, so it's hard to answer. Assuming you can use .NET, WCF with a named-pipes binding would be very simple. Just a few lines of code to set it up.

nitzmahone
Thanks for you answer. Yes, i'm using .NET (2.0), so i can implement named pipes support. However how do i use it from the gadget? I did a quick search and did not find any examples.
Muxa
There's nothing special about doing this from a gadget- just google for 'WCF named pipes example'. You'd need to use at least .NET 3.0 to get WCF though (you can do named pipe stuff in 2.0 directly with PInvoke, but it's nasty).
nitzmahone
A: 

We use win32 APIs in one of our gadgets' ActiveX control to communicate with other instances of the same gadget. Unfortunately, I can't give you the code (because I don't have permission and I don't write the .net stuff) but it boils down to using a window (in your case the application window) as a server and the gadget ActiveX control as the client and use the SendMessage function.

You can see an example of using COM interop with windows desktop gadgets at http://www.codeproject.com/KB/gadgets/GadgetInterop.aspx

NB: make sure the interop assembly is in the application's directory and NOT the gadget directory, otherwise you'll run into problems when updating/uninstalling the gadget.

Andy E