ChupaChu Posted September 7, 2007 Share Posted September 7, 2007 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
ragdog Posted September 7, 2007 Share Posted September 7, 2007 hi try this http://www.cppfrance.com/code.aspx?ID=26858i hope it helps yougreetsragdog Link to comment
s0me0ne Posted September 7, 2007 Share Posted September 7, 2007 try function KillProcessByPID(PID: DWORD): Boolean;beginResult := TerminateProcess(OpenProcess(PROCESS_TERMINATE, False, PID), 0);end;or have a look here:http://www.delphipages.com/threads/thread....96&G=168165 Link to comment
ChupaChu Posted September 7, 2007 Author Share Posted September 7, 2007 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
ChupaChu Posted September 7, 2007 Author Share Posted September 7, 2007 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now