[英]How can I show visual studio process created using EnvDTE
I have an app that can help to explore, generate and open visual studio projects.我有一个应用程序可以帮助探索、生成和打开 Visual Studio 项目。 I'm creating the visual studio process using the Activator method as follows:
我正在使用 Activator 方法创建 Visual Studio 进程,如下所示:
using System;
using System.Windows.Forms;
using EnvDTE80;
using System.Runtime.InteropServices;
namespace TestWindowsApp
{
static class Program
{
[DllImport("user32.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Type type = Type.GetTypeFromProgID("VisualStudio.DTE.14.0");
DTE2 dte = (DTE2)Activator.CreateInstance(type, true);
dte.MainWindow.Visible = true;
dte.UserControl = true;
SetForegroundWindow((IntPtr)dte.MainWindow.HWnd);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
It works great except the process it creates is hidden.除了它创建的过程被隐藏之外,它工作得很好。 If I use Process Explorer's "Find Window's Process" feature I get the error:
如果我使用 Process Explorer 的“Find Window's Process”功能,我会收到错误消息:
Is there any way to use this method but make the process visible?有什么方法可以使用此方法但使过程可见? It makes working with the spawned visual studio a bit harder than if you open it manually.
与手动打开它相比,它使使用衍生的 Visual Studio 变得更加困难。
尝试文件 > 显示所有进程的详细信息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.