1

我试图杀死所有打开的 powerpoint 进程,但我编写的代码只杀死了一个打开的进程。

    '-- get a collection of processes running
    Dim foo() As System.Diagnostics.Process = System.Diagnostics.Process.GetProcesses
    '-- go through each one looking for the internet explorer name
    For Each temp As Diagnostics.Process In foo

        'For Word Files opened in Office
        If temp.ProcessName = "POWERPNT" Then
            temp.Kill() '-- if I find it, kill it.
            '                Exit For '-- exit the for loop
        End If
4

2 回答 2

1

尝试

Dim foo() as process = Process.GetProcessByName("POWERPNT")

For Each temp As Process In foo

    temp.Kill()

Next
于 2013-08-20T04:50:21.047 回答
0

You are only going to find the single instance of the POWERPNT.exe, because

Multiple instances of Word (Winword.exe), Excel (Excel.exe), and Microsoft Access (MSAccess.exe) can run simultaneously. Therefore, these servers are defined as Single Use (Multiple Instances) servers. Only one instance of PowerPoint (Powerpnt.exe) can run at any given time. Therefore, PowerPoint is a Multiuse (Single Instance) server.

Read How to use Visual C# to automate a running instance of an Office program for complete documentation.

于 2013-08-19T18:20:13.770 回答