gpt4 book ai didi

c# - 为什么我创建的列表中没有名称的特定过程?

转载 作者:行者123 更新时间:2023-11-30 19:18:34 25 4
gpt4 key购买 nike

我有这个功能可以检查进程是否启动以及何时退出。但是我在 IF 上的断点上使用并且列表计数始终为 0。

当我运行任务管理器时,我看到了 bf3.exe *32那么这里出了什么问题?

private void isProcessRunning()
{
Process[] proclist = Process.GetProcessesByName("bf3.exe");

if (proclist.Length > 0)
{
Logger.Write("Battlefield 3 Started");
alreadyRun = true;
}
else if (alreadyRun == true)
{
Logger.Write("Battlefield 3 Exited");
}
}

最佳答案

来自documentation :

The process name is a friendly name for the process, such as Outlook, that does not include the .exe extension or the path. GetProcessesByName is helpful for getting and manipulating all the processes that are associated with the same executable file. For example, you can pass an executable file name as the processName parameter, in order to shut down all the running instances of that executable file.

强调我的。

关于c# - 为什么我创建的列表中没有名称的特定过程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12204914/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com