我正在尝试监视用户选择的进程。我正在做的是尝试从进程名称中获取文件名,以便在找不到进程时可以再次启动它。现在我不明白我的问题。我在这里收到错误:Dim s As String = ProcessArray(0).MainModule.FileName
。
我不明白的是它返回的文件名很好。谁能帮我查明问题?
Dim ProcessArray As Process()
ProcessArray = Process.GetProcessesByName(procName)
Dim s As String = ProcessArray(0).MainModule.FileName
Dim f As Process
Dim p As Process() = Process.GetProcessesByName(procName)
For Each f In p
If p.Length > 0 Then
For i As Integer = 0 To p.Length - 1
ProcessID = (p(i).Id)
Next
Else
ProcessID = 0
End If
If ProcessID = 0 Then
BotRunning = False
Process.Start(s)
watchdogbool = True
RunBot(watchdogList, ItemClicked.Text, -1)
End If
Next