用于文件关联的 dde ​​的最佳 .net 替代方案是什么?

发布于 2024-08-01 13:34:59 字数 484 浏览 2 评论 0原文

我有一个 MDI Windows 窗体应用程序 (.net 2008),它允许用户将各种文件类型与该应用程序关联。 我目前使用类似这样的注册表项执行此操作,这会导致应用程序通过命令行加载并访问文件名:

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

在应用程序的 .net 之前版本中,我使用了 DDE(注册表中的 ddeexec)。 如果在 Windows 资源管理器中双击文件时正在执行应用程序的实例,则它将打开该文件,而无需启动应用程序的新实例。

既然 Microsoft 已弃用 DDE,那么当在资源管理器中双击文件时,执行 MDI 应用程序在 .net 中打开其他文件(而不是启动应用程序的新实例)的最佳方式是什么?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

顾挽 2024-08-08 13:34:59

理想情况下,您可以使用常规文件关联技术 (doc< /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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文