
Terminate Process and SecurityIno ?
Here an example how to terminate a process by name...
This example works under win98/2000 for other win versions you need a
correct toolhelp.dll
But this will also not solve my problem. Some processes are protected
from the system, if you want kill them it oocurs error 5, Access denied.
If you make any progress at this problem, please let me know...
thanks...
sincere Mark
#include "Tlhelp32.h"
void CKillRepAppDlg::OnTimer(UINT nIDEvent)
{
PROCESSENTRY32 ProcEntry;
HANDLE hSnapShot = CreateToolhelp32Snapshot
(TH32CS_SNAPPROCESS,0);
if (Process32First(hSnapShot,&ProcEntry))
{
while(Process32Next(hSnapShot,&ProcEntry))
{
CString szExeFile = ProcEntry.szExeFile;
szExeFile.MakeUpper();
if(szExeFile=="YOUR.EXE")
{
HANDLE hProc = OpenProcess
(PROCESS_TERMINATE,FALSE,ProcEntry.th32ProcessID);
if (hProc) TerminateProcess(hProc,0);
CloseHandle(hProc);
}
}
}
CloseHandle(hSnapShot);
Quote:
}
Quote:
> I am also trying to do the same thing too. If you make any progress,
please
> post it here. Is writing a C++ program the only way to terminate a
process?
> Thanks.
> hzg.
> > hi,
> > i am also trying on such a program. Can i ask a question about
that ? how
> > can i take the handle of process if ony if i know only its name ?
> > > Hello again...
> > > I have tried to write an application that termineates any process
on my
> > > win2000 machine. But some processes could be terminated normally
with
> > > the TerminateProcess() Method. Somewhere has answered to me that
I must
> > > open the Process in debug mode or modify the security context. But
> > > how ? Can anyone show me how I can modify the Security rights of
an
> > > process that is not mine. Sure I'm administrator on my machine
but how
> > > can I terminate processes that are not my own ?
> > > I have read aboout Get/SetSecutityInfo() but without an example
is this
> > > a little difficult, and I don't have any Idea if this could be the
> > > right way ?
> > > thanks for each answear....
> > > sincere M.Egloff
> > > --
> //////////////////////////////////////////////////////////////////////
//
> > > // Egloff Mark KabelNewMedia
> > > // Dipl. Ingenieur Nussgasse 4, CH-8008 Zurich
> //////////////////////////////////////////////////////////////////////
//
> > > The flesh is a trap but the magic gives us the freedom.....
> > > Sent via Deja.com
> > > http://www.deja.com/
--
////////////////////////////////////////////////////////////////////////
// Egloff Mark KabelNewMedia
// Dipl. Ingenieur Nussgasse 4, CH-8008 Zurich
////////////////////////////////////////////////////////////////////////
The flesh is a trap but the magic gives us the freedom.....
Sent via Deja.com
http://www.deja.com/