Board index » delphi » Kill process

Kill process

Hi, NG,

  Does anyone know how could I get all processes in Windows and close those
having particular file names? I need it to be done programmatically.. Some
kind of Task manager.

  Thanks
  Alex Shlega

**********************************
ComKast meta search:
http://a1385.svwh.net/comkast/search
**********************************

 

Re:Kill process


Use the functions from TLHelp32 (Windows 9x) or PSApi (Windows NT) to get a
list of processes and send a WM_QUIT to the handle to terminate the process.

"Alexander Shlega" <ashl...@airlineguides.com> schreef in bericht
news:95mbiv$kj$1@news.wplus.spb.ru...

Quote
> Hi, NG,

>   Does anyone know how could I get all processes in Windows and close
those
> having particular file names? I need it to be done programmatically.. Some
> kind of Task manager.

>   Thanks
>   Alex Shlega

> **********************************
> ComKast meta search:
> http://a1385.svwh.net/comkast/search
> **********************************

Re:Kill process


Quote
"M.H. Avegaart" <avegaartNOS...@mccomm.nl> wrote in message

news:95me3c$iau$1@porthos.nl.uu.net...
Quote
> Use the functions from TLHelp32 (Windows 9x) or PSApi (Windows NT) to get
a
> list of processes and send a WM_QUIT to the handle to terminate the

process.

Yes, I have found them(I use PSApi).. So I have the following sequence:

1. EnumProcesses
2. EnumProcessModules
3. GetModuleFileNameEx

However when I call GetModuleFileNameEx I get access violation. I suppose I
need this function to determine file names?

  Thanks
  Alex

Re:Kill process


I think you are using one of the functions wrong. I don't have a Delphi
example, but the Microsoft support site has a C++ example you can learn
from:
http://support.microsoft.com/support/kb/articles/Q175/0/30.asp

"Alexander Shlega" <ashl...@airlineguides.com> schreef in bericht
news:95mfae$5ml$1@news.wplus.spb.ru...

Quote
> "M.H. Avegaart" <avegaartNOS...@mccomm.nl> wrote in message
> news:95me3c$iau$1@porthos.nl.uu.net...
> > Use the functions from TLHelp32 (Windows 9x) or PSApi (Windows NT) to
get
> a
> > list of processes and send a WM_QUIT to the handle to terminate the
> process.

> Yes, I have found them(I use PSApi).. So I have the following sequence:

> 1. EnumProcesses
> 2. EnumProcessModules
> 3. GetModuleFileNameEx

> However when I call GetModuleFileNameEx I get access violation. I suppose
I
> need this function to determine file names?

>   Thanks
>   Alex

Re:Kill process


this will enumerate processes

uses TlHelp32;

function EnumProcesses : TStringList;
var
ProcHandle : THandle;
AProcEntry : TProcessEntry32;
List : TStringList;

begin
  ProcHandle:=CreateToolHelp32SnapShot(TH32CS_SNAPPROCESS,0);
  if ProcHandle = -1 then Exit;
  AprocEntry.dwSize:=SizeOf(TProcessEntry32);
  if Process32First(ProcHandle, AProcEntry) then
    begin
       List:=TStringList.Create;
       List.Add(AProcEntry.szExeFile);
       while Process32Next(ProcHandle,AProcEntry) do
        begin
           List.Add(AProcEntry.szExeFile);
        end;
     end;
  CloseHandle(ProcHandle);
  Result:=List;
end;

Quote
"Alexander Shlega" <ashl...@airlineguides.com> wrote in message

news:95mbiv$kj$1@news.wplus.spb.ru...
Quote
> Hi, NG,

>   Does anyone know how could I get all processes in Windows and close
those
> having particular file names? I need it to be done programmatically.. Some
> kind of Task manager.

>   Thanks
>   Alex Shlega

> **********************************
> ComKast meta search:
> http://a1385.svwh.net/comkast/search
> **********************************

Re:Kill process


Waht's the difference between sending a WM_CLOSE and a WM_QUIT message?

Quote
"M.H. Avegaart" <avegaartNOS...@mccomm.nl> wrote in message

news:95me3c$iau$1@porthos.nl.uu.net...
Quote
> Use the functions from TLHelp32 (Windows 9x) or PSApi (Windows NT) to get
a
> list of processes and send a WM_QUIT to the handle to terminate the
process.

> "Alexander Shlega" <ashl...@airlineguides.com> schreef in bericht
> news:95mbiv$kj$1@news.wplus.spb.ru...
> > Hi, NG,

> >   Does anyone know how could I get all processes in Windows and close
> those
> > having particular file names? I need it to be done programmatically..
Some
> > kind of Task manager.

> >   Thanks
> >   Alex Shlega

> > **********************************
> > ComKast meta search:
> > http://a1385.svwh.net/comkast/search
> > **********************************

Re:Kill process


Quote
> example, but the Microsoft support site has a C++ example you can learn
> from:
> http://support.microsoft.com/support/kb/articles/Q175/0/30.asp

  Thanks. That's what I needed.

Alex

Other Threads