get the program id of an excel application from the task manager

  • Thread starter Thread starter nikolaosk
  • Start date Start date
N

nikolaosk

hi there,

i have this problem. i have an application written in delphi that fires
up excel applications, so these applications get a PID from the
system.

what i need to do is to kill the excel applications by getting their
PID from task manager!!!!!!!!!!


how do i do that?


thanks a lot


nikos
 
hi there,

i have this problem. i have an application written in delphi that fires
up excel applications, so these applications get a PID from the
system.

what i need to do is to kill the excel applications by getting their
PID from task manager!!!!!!!!!!


how do i do that?

I don't know anything about Delphi's capabilities; there are a whole
bunch of Delphi related newsgroups, i.a. at borland.public.delphi...,
maybe they can provide a specific answer.

But as Delphi can obviously spawn other processes, you could probably use
TLIST and KILL from the NT Resource Kit, or pslist and pskill from the
PsTools set <http://www.sysinternals.com/ntw2k/freeware/pstools.shtml>.
 
Don't know about delphi but on a WinXP or Win2k system you should be able to
use wmi.

For example, this sub run in VBA would reveal the PID of a running instance
of Excel.

Sub getPID()
For Each Process In
GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_pr
ocess")
If Process.Name = "EXCEL.EXE" Then
MsgBox Process.Handle
End If
Next
End Sub

Steve
 
Back
Top