Process.Collection 属性

返回包含某个对象的集合,该对象支持此属性或包含在此代码构造中。 对于不是从集合中获得的对象,返回 null。

命名空间:  EnvDTE
程序集:  EnvDTE(在 EnvDTE.dll 中)

语法

声明
ReadOnly Property Collection As Processes
    Get
Processes Collection { get; }
property Processes^ Collection {
    Processes^ get ();
}
abstract Collection : Processes
function get Collection () : Processes

属性值

类型:EnvDTE.Processes
一个 Processes 集合。

示例

下面的示例演示如何使用 Collection 属性。

要测试此属性

  • 打开目标项目并运行外接程序。
public static void Collection(DTE dte)
{
    // Setup debug Output window.
    Window w = (Window)dte.Windows.Item(EnvDTE.Constants.vsWindowKindOutput);
    w.Visible = true;
    OutputWindow ow = (OutputWindow)w.Object;
    OutputWindowPane owp = ow.OutputWindowPanes.Add("Collection Property Test");
    owp.Activate();

    EnvDTE.Process process = dte.Debugger.LocalProcesses.Item(1);
    owp.OutputString("Number of items in the process collection is " + 
        process.Collection.Count + ": ");
    foreach(EnvDTE.Process proc in process.Collection)
        owp.OutputString("\n" + proc.Name + "  ");
}
Shared Sub Collection(ByRef dte As EnvDTE.DTE)
    Dim process As EnvDTE.Process = dte.Debugger.LocalProcesses.Item(1)
    Dim str As String = vbCrLf
    str = "There are " + process.Collection.Count.ToString()
    str += " items in the process collection: "
    For Each proc As EnvDTE.Process In process.Collection
        str += vbCrLf + proc.Name + "  "
    Next
    MessageBox.Show(str, "Process Test - Collection Property")
End Sub

.NET Framework 安全性

请参见

参考

Process 接口

EnvDTE 命名空间

其他资源

如何:编译和运行自动化对象模型代码示例