通过代码中的使用实例获取进程的PID

时间:2018-08-16 08:01:01

标签: c# com

我想知道是否有可能从实例中获取COM ActiveX Server的pid:

myObject test = new myObject(); //Create an exe in tasklist

//get its PID
int pid = ...

//get the process
Process myProcess = Process.GetProcessById(pid);

//kill the process
proc.Kill();

我无法使用foreach循环来获取该进程,因为我可以拥有该COM Server的多个进程,并且我想在工作完成后杀死该好实例。

通常,该工作完成后会自动销毁,但万一不是...

谢谢

编辑:我在VB6代码中添加了一个吸气剂,该Getter通过使用GetCurrentProcessID返回pid,并且我用C#获取了该过程,并且它运行良好。

0 个答案:

没有答案