Process ID

How Can I shutdown some application
if I have it's process ID ???
zekoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TheNeilCommented:
You could send it a WM_CLOSE message

The Neil
0
DrDelphiCommented:
Actually, Wm_Close assumes that you are trying to close a windowed application. If it were a service or a console application, WM_Close would not be the way to go. I'd suggest looking at TerminateProcess instead.

Good luck!!
0
TheNeilCommented:
DrDelphi,

You're right - if my stupid brain was working I'd have remembered TerminateProcess

The Neil
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

MadshiCommented:
zeko, use OpenProcess to obtain a process handle from the process ID, then call TerminateProcess with the process handle.

Regards, Madshi.

P.S: Something like this:

ph := OpenProcess(PROCESS_ALL_ACCESS, false, pid);
TerminateProcess(ph, 0);
0
zekoAuthor Commented:
Thanks Madshi
Post me an answer.
0
MadshiCommented:
Dr. Delphi, The Neil, is that okay for you?

zeko, you can accept my comment as the answer (see the link in the top right corner of the comments).
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
zekoAuthor Commented:
You posted me the full source code.
You earned it.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.