如何添加新进程已打开 [英] how to add the new process was opened

查看:80
本文介绍了如何添加新进程已打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我有一个非常重要的项目,它是计算机操作中的监视器



如果窗口已经打开了一个新操作项目。



我在formLoad事件中使用了这段代码:

Hello, I have a very important project, which is a monitor in the computer operations

The project is show if the window has been opened a new operation.

I used this code in formLoad event:

For Each p In Process.GetProcesses
         old_list.Items.Add (p.ProcessName)
     Next



在计时器中打勾:


In timer tick:

new_list.Items.Clear ()

For Each p In Process.GetProcesses
    new_list.Items.Add (p.ProcessName)
Next
If old_list.Items.Count = new_list.Items.Count Then

Else
    Form2.Show ()
    Me.Close ()
End If



现在当你打开一个新进程时会出现form2 2,现在我该怎么办知道新进程的名称吗?


Now when you open a new process will appear form2 2, now how do I know the name of the new proccess?

推荐答案

嗯,对于初学者,我可以告诉你你的如果声明是垃圾。你假设一个进程永远不会在另一个进程退出的同时启动。你的逻辑是有缺陷的。您无法将最后一次传递的进程数与最新传递中的进程数进行比较,并从中得出任何结论。



因为你已经得到了并迭代GetProcesses返回的整个流程列表并将流程名称列表添加到列表中,您已经拥有每个流程的名称。
Well, for starters, I can tell you that your if statement is garbage. You''re assuming that a process never starts at the same time another process exits. Your logic is flawed. You cannot compare the number of processes on the last pass with the number of processes in the latest pass and draw any conclusions from it.

Since you''re already getting and iterating over the entire process list returned by GetProcesses and adding the list of process names to a list, you already have the name of every process.


这篇关于如何添加新进程已打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆