如何从资源管理器中打开文件到不同的选项卡

时间:2022-12-15 00:29:08

How to open files from explorer into different tabs. I can associate an open with menu with the file type, now when I already have the program working, how to open the new file into another tab, instead of new program. How to find the already running process exactly, not with the name and send the filename to it.

如何从资源管理器中打开文件到不同的选项卡。我可以将打开菜单与文件类型相关联,现在当我已经有程序工作时,如何将新文件打开到另一个选项卡,而不是新程序。如何准确地找到已经运行的进程,而不是使用名称并将文件名发送给它。

Let me make myself clear: I want my app to be single instance, so that when user select 10 text files and press enter key, my application will open all the 10 text files into 10 tabs, instead of creating 10 processes. How to do that? How to communicate between various instances of the same process.

让我自己说清楚:我希望我的应用程序是单个实例,这样当用户选择10个文本文件并按回车键时,我的应用程序将打开所有10个文本文件到10个选项卡,而不是创建10个进程。怎么做?如何在同一进程的各种实例之间进行通信。

EDIT SOLVED: Implemented the functionality using WM_COPYDATA in C# and the SingleApplication class from codeproject.

EDIT已解决:使用C#中的WM_COPYDATA和codeproject中的SingleApplication类实现功能。

1 个解决方案

#1


I am not quite sure what you mean in this question. Are you trying to open Windows Explorer windows into one window with tabs? If that is the case, then I recommend you look into QT TabBar, which extends Windows Explorer to allow for such behavior.

我不太清楚你在这个问题上的意思。您是否尝试使用选项卡将Windows资源管理器窗口打开到一个窗口中?如果是这种情况,那么我建议您查看QT TabBar,它扩展了Windows资源管理器以允许此类行为。

Or perhaps you are trying to have a link open to a new tab in a web browser. If that is the case, this behavior is defined by the web browser itself. For Internet Explorer 7, you can set this behavior under Tools > Internet Options.

或者您可能正在尝试在Web浏览器中打开一个新选项卡的链接。如果是这种情况,则此行为由Web浏览器本身定义。对于Internet Explorer 7,您可以在“工具”>“Internet选项”下设置此行为。

In the General tab, click the Settings button next to the "Tabs" section. You will want to set the "Open links from other programs in:" option to open a new tab.

在“常规”选项卡中,单击“选项卡”部分旁边的“设置”按钮。您需要设置“从其他程序打开链接:”选项以打开新选项卡。

Keep in mind that this behavior is defined by each user, and you can't ever make any guarantees that they will have the same browser settings as you do.

请记住,此行为是由每个用户定义的,您无法保证他们将拥有与您相同的浏览器设置。


After reading your comments, I think I understand a bit better. It sounds like you want your application to only allow one instance at a time. Since you tagged this post C#, I will assume that is what you are writing your program in.

看完你的评论后,我想我明白了一点。听起来您希望您的应用程序一次只允许一个实例。既然你标记了这篇文章C#,我会假设你正在编写你的程序。

Codeproject.com has a great tutorial on how to make your program only allow a single instance.

Codeproject.com有一个很棒的教程,介绍如何让你的程序只允许一个实例。

Here is a snippet of code from their site:

以下是其网站的代码片段:

static void Main() 
{
   if(SingleInstance.SingleApplication.Run() == false)
   {
      return;
   }
   //Write your program logic here
}

You would want to write code just before the return statement to have the existing instance open the file in a new tab.

您可能希望在return语句之前编写代码,以使现有实例在新选项卡中打开文件。

If you are able to provide detailed information about what your program is doing, we might be able to help you with some of the specifics.

如果您能够提供有关您的计划正在做什么的详细信息,我们可能会帮助您了解一些具体细节。

#1


I am not quite sure what you mean in this question. Are you trying to open Windows Explorer windows into one window with tabs? If that is the case, then I recommend you look into QT TabBar, which extends Windows Explorer to allow for such behavior.

我不太清楚你在这个问题上的意思。您是否尝试使用选项卡将Windows资源管理器窗口打开到一个窗口中?如果是这种情况,那么我建议您查看QT TabBar,它扩展了Windows资源管理器以允许此类行为。

Or perhaps you are trying to have a link open to a new tab in a web browser. If that is the case, this behavior is defined by the web browser itself. For Internet Explorer 7, you can set this behavior under Tools > Internet Options.

或者您可能正在尝试在Web浏览器中打开一个新选项卡的链接。如果是这种情况,则此行为由Web浏览器本身定义。对于Internet Explorer 7,您可以在“工具”>“Internet选项”下设置此行为。

In the General tab, click the Settings button next to the "Tabs" section. You will want to set the "Open links from other programs in:" option to open a new tab.

在“常规”选项卡中,单击“选项卡”部分旁边的“设置”按钮。您需要设置“从其他程序打开链接:”选项以打开新选项卡。

Keep in mind that this behavior is defined by each user, and you can't ever make any guarantees that they will have the same browser settings as you do.

请记住,此行为是由每个用户定义的,您无法保证他们将拥有与您相同的浏览器设置。


After reading your comments, I think I understand a bit better. It sounds like you want your application to only allow one instance at a time. Since you tagged this post C#, I will assume that is what you are writing your program in.

看完你的评论后,我想我明白了一点。听起来您希望您的应用程序一次只允许一个实例。既然你标记了这篇文章C#,我会假设你正在编写你的程序。

Codeproject.com has a great tutorial on how to make your program only allow a single instance.

Codeproject.com有一个很棒的教程,介绍如何让你的程序只允许一个实例。

Here is a snippet of code from their site:

以下是其网站的代码片段:

static void Main() 
{
   if(SingleInstance.SingleApplication.Run() == false)
   {
      return;
   }
   //Write your program logic here
}

You would want to write code just before the return statement to have the existing instance open the file in a new tab.

您可能希望在return语句之前编写代码,以使现有实例在新选项卡中打开文件。

If you are able to provide detailed information about what your program is doing, we might be able to help you with some of the specifics.

如果您能够提供有关您的计划正在做什么的详细信息,我们可能会帮助您了解一些具体细节。