[英]How can I show visual studio process created using EnvDTE
我有一個應用程序可以幫助探索、生成和打開 Visual Studio 項目。 我正在使用 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());
}
}
}
除了它創建的過程被隱藏之外,它工作得很好。 如果我使用 Process Explorer 的“Find Window's Process”功能,我會收到錯誤消息:
有什么方法可以使用此方法但使過程可見? 與手動打開它相比,它使使用衍生的 Visual Studio 變得更加困難。
嘗試文件 > 顯示所有進程的詳細信息
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.