如何在Visual Studio(2008)的特定实例中打开源文件 [英] How to open source file in specific instance of Visual Studio (2008)

查看:153
本文介绍了如何在Visual Studio(2008)的特定实例中打开源文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个Visual Studio 2008的实例打开,我想在特定实例中打开源文件。
我计划用Win32 API和类似 ShellExecute(...)这样做,但我还是找不到解决方案。

I have several instances of Visual Studio 2008 opened and I want to open a source file in a specific instance. I plan to do this with Win32 API and something like ShellExecute(...), but I can't find solution yet.

有办法吗?任何想法?

推荐答案

除非应用程序打开文件(VS2008)有一个消息处理程序设置启动打开文件确定如果它是否是否;这将是最简单的方法),你可能可以模拟文件拖放到应用程序的客户区(通过消息直接发送到客户端窗口的消息处理程序)。你需要得到VS2008的客户端窗口的句柄为您发送消息的实例。

Unless the application opening the file (VS2008) has a message handler set up to initiate opening a file (not sure if it does or not; this would be the easiest method), you could probably simulate a drag-and-drop of the file to the application's client area (via message sending directly to the client window's message handler). You would need to get a handle to the client window of VS2008 for the instance you are sending the message to.

不知道目的是什么。你通常可以调用一个新的实例来使用ShellExecute()打开文件,但这不会引用已经运行的特定实例。

Don't know what the purpose would be, though. You can generally call up a new instance to open the file using ShellExecute(), but that wouldn't refer to a specific instance that is already running.

另一种方法可能考虑的是钩子VS2008的消息处理程序为主窗口,并记录发送与菜单命令相关的所有消息。您可能可以确定是否存在与打开文件相关联的消息事件。确定发送到WndProc()函数的参数将是另一个故事。希望它将作为字符串指针(文件名)发送到lParam。

Another method you might consider is to hook VS2008's message handler for the main window, and log all messages sent relating to menu commands. You might be able to determine if there is a message event associated with opening a file. Figuring out the parameters sent to the WndProc() function would be another story. Hopefully it would be sent as a string pointer (for the filename) to lParam.

这篇关于如何在Visual Studio(2008)的特定实例中打开源文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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