什么是最好的.NET替代DDE文件关联? [英] What is the best .net alternative to dde for file associations?

查看:168
本文介绍了什么是最好的.NET替代DDE文件关联?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MDI Windows窗体应用程序(.NET 2008),它允许用户在不同的文件类型与应用程序相关联。我现在做一个注册表项,这样的事情,导致应用程序加载和通过命令行访问的文件名:

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""")

在应用程序的pre-.net版本,我用的DDE(ddeexec在注册表中)。如果应用程序的一个实例正在执行时,文件双击在Windows资源管理器,这将不启动应用程序的新实例,打开该文件。

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.

现在的DDE已经去微软pcated $ P $,什么是.NET的一个执行MDI应用程序文件的时候双击在资源管理器中打开一个附加文件的最好方法,而不是开始一个新的该应用程序的实例?

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?

推荐答案

那么理想情况下,你可以使用普通的文件关联技术(的 DOC ),以及某种形式的进程间通信来组织你的程序如何处理后续启动。

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.

下面(<一href="http://stackoverflow.com/questions/50153/interprocess-communication-for-windows-in-c-net-2-0/50180#50180">link)是一个很好的SO回答您开始使用了。

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

这篇关于什么是最好的.NET替代DDE文件关联?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆