打开所有的文件时,用户右键点击,选择"打开方式" [英] Open all files when user right clicks and selects "Open With"

查看:149
本文介绍了打开所有的文件时,用户右键点击,选择"打开方式"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写在WPF / C#中,可以采取多个文件作为命令行参数的应用程序。当我从多个文件命令行中运行它,它会打开所有的人。当我在浏览器窗口中选择多个文件并将它们拖到应用程序图标,它会打开所有的人。但是,如果我选择在资源管理器中,右键点击多个文件,选择打开方式,然后选择我的应用程序只打开最后一个。有没有一种方法来告诉Windows我的应用程序可以处理多个文件?我注意到,一些程序似乎工作的方式,而有的则没有。

I have an application written in WPF/C# that can take multiple files as command line arguments. When I run it from the command line with multiple files it opens all of them. When I select multiple files in an explorer window and drag them to the applications icon it opens all of them. But if I select multiple files in explorer and right click, select Open With, and then select my application it only opens the last one. Is there a way to tell Windows that my application can handle more than one file? I've noticed that some programs seem to work that way while others do not.

推荐答案

外壳实际上是试图启动一个单独的您的应用程序实例的每个的文件中选择。你的应用需要(一)确保只有第一个实例实际显示其UI,和(b)做一些进程间通信从后来的情况下,文件传递给第一个实例。你可能已经这样做(一),而不是(B),这可以解释为什么你只看到一个文件打开得到。见第二个问题(关于单实例应用程序的部分)在斯蒂芬Toub的帖子的这个问题。您可能还需要阅读有关动态数据交换(DDE),该是通过一个应用程序实例之间的信息的常用方法。

The shell actually tries to start a separate instance of your application for each file selected. Your app will need to (a) ensure that only the first instance actually shows its UI, and (b) do some inter-process communication to pass the files from the later instances to the first instance. You might already be doing (a), but not (b), which would explain why you only see one file get opened. See the second question (the part about "Single-Instance Apps") on Stephen Toub's post about this. You also may want to read about Dynamic Data Exchange (DDE), which is a common way to pass information between instances of an application.

这篇关于打开所有的文件时,用户右键点击,选择"打开方式"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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