Friday, May 02, 2008

I love this.   A couple of pinvokes to make two applications talk to each other.

To send messages to another application you need the following -

[DllImport("coredll.dll")]
  public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

  [DllImport("coredll.dll")]
  public static extern int SendMessage(IntPtr window, int message, int wparam, int lparam);

Which respectively allow one application to get the window handle on another,  then send a message.

One the receiver side,  its a snap just override the following -

protected override void WndProc(ref Message msg)
{

}

I'm not really filling in all the gaps here I know, but I'll let you explore it works really great.   

Friday, May 02, 2008 10:03:43 PM UTC  #    Comments [0]  | 

Theme design by Jelle Druyts

Pick a theme: