所以,现在工作正常
Process.GetProcessesByName("ProcessName")[0].CloseMainWindow();
现在,我该如何检查它是否存在,这是不行的:
if ( Process.GetProcessesByName("ProcessName")[0] != null ) {...}
Process[] processes = Process.GetProcessesByName("ProcessName"); if (processes.Length > 0) processes[0].CloseMainWindow();