AngeloX
asked on
Shutting down another program.
Hey guys n gals,
Do you have the code to shut down another program with the PID of that program (you dont have to write how to get the PID, just how to shut down a program by using its PID).
If it's not possible to shut down a program by using its PID, then do you know how to get a windows handle of a PID to shut down a program by using its windows handle.
If it's not possible to get a window handle from a PID, then do you know how to find a Window Classname by Filename.
Thnx!
Do you have the code to shut down another program with the PID of that program (you dont have to write how to get the PID, just how to shut down a program by using its PID).
If it's not possible to shut down a program by using its PID, then do you know how to get a windows handle of a PID to shut down a program by using its windows handle.
If it's not possible to get a window handle from a PID, then do you know how to find a Window Classname by Filename.
Thnx!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if you know the pid then use this code:
procedure TForm1.Button1Click(Sender : TObject);
const PROCESS_MURDER = $0001;
var pid: Cardinal;
ProcessHandle: THandle;
begin
pid := $00000F5C; //process id here
ProcessHandle := OpenProcess(PROCESS_MURDER , FALSE, pid);
TerminateProcess(ProcessHa ndle,4);
end;
procedure TForm1.Button1Click(Sender
const PROCESS_MURDER = $0001;
var pid: Cardinal;
ProcessHandle: THandle;
begin
pid := $00000F5C; //process id here
ProcessHandle := OpenProcess(PROCESS_MURDER
TerminateProcess(ProcessHa
end;
ASKER
Yeah indeed. I replied too fast, was just about to post that hehe.
Thnx! Points given.
Thnx! Points given.
ASKER
If I had the WindowName I didnt have to post here, but I only have the PID and the FileName of the program. Any ideas?
Thnx!