views:

351

answers:

1

I have an MDI Windows Forms application (.net 2008) that allows the user to associate various file types with the application. I currently do this with a registry entry something like this, that causes the application to load and access the file name via the command line:

Registry.SetValue(appKey & "\shell\open\command", "", """" & _
  System.Windows.Forms.Application.ExecutablePath & """ ""%1""")

In the pre-.net version of the application, I used DDE (ddeexec in the registry). If an instance of the application was executing when a file was double-clicked in Windows Explorer, it would open the file without starting up a new instance of the application.

Now that DDE has been deprecated by Microsoft, what is the best way in .net for an executing MDI application to open an additional file when the file is double-clicked in Explorer, as opposed to starting a new instance of the application?

A: 

Well ideally, you could use regular file association techniques (doc), along with some form of inter-process communication to organize how your program handles subsequent launches.

For instance, when your program starts, check if another instance is already open. If so, pass any parameter data to the existing instance, and quit. The existing instance then handles the data appropriately.

Here (link) is a good SO answer to get you started with that.

Factor Mystic