Jump to content
Tuts 4 You

Terminateprocess Does Not Work Every Time


ChupaChu

Recommended Posts

I want to be able to kill EVERY process no mather what,

but it seems code i'm using is not good enough to do that.

Here is what i use:

I find handle of process using something like this

hProcess:= OpenProcess(PROCESS_ALL_ACCESS, TRUE, aProcessId);

Then i try to kill it with this:

TerminateProcess(hProcess, 0);

Problem is it works with notepad and similar programs, but not

with many others.. :)

Any sugestions?

Regards,ChupaChu!

Link to comment
try

function KillProcessByPID(PID: DWORD): Boolean;

begin

Result := TerminateProcess(OpenProcess(PROCESS_TERMINATE, False, PID), 0);

end;

or have a look here:

http://www.delphipages.com/threads/thread....96&G=168165

I think there is problem with time i leave for process to terminate..

i just saw this line:

for i:=0 to 5000 do Application.ProcessMessages; 
//Genug Zeit geben - what would mena give enough time to terminate i guess :)

Next thing PROCESS_ALL_ACCESS or PROCESS_TERMINATE !?

Somebody said to me that if you want to kill proces without

waiting for anything use all_access..

I will try later today and give feedback how it turns out to be :)

Thanks!

Link to comment

I tried PROCESS_TERMINATE instead of PROCESS_ALL_ACCESS and what i get is:

"Access violation at address 004xxxx in module "mymodule.exe". Read of address 00000000."

When I change it back to PROCESS_TERMINATE guess what - the same error!!

Now what was working does not work.. arghhh..

Look like i will have to read deeper into this..

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...