Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Process Management

  1. #1

    Process Management

    Hello,

    I have been trying to figure out how to Terminate a process in Delphi, and I saw shockingly long of code which i don't think I can remember, and i don't even understand what it means.

    Could someone please show me the simplest way (but not a bad way) in which i can terminate a process in Delphi?

    and also start processes and check to see if they are running, and how to get a list of running processes.

    Thank you.
    Nicholas.
    <br />
    <br />Please join: http://holzstukka.proboards81.com

  2. #2

    Process Management

    Halt
    Application.Terminate

    Goto: http://www.swissdelphicenter.ch/torry/
    [size=9px]BEGIN GEEK CODE BLOCK
    <br />d s-- : a24 GB GCS GTW GE C++ P L+ W++ N+ K- w++++ M- PS+ PE+ Y- t+ 5+++ X+ R*
    <br />tv b+ DI++ D+ e++ h+ G-
    <br />END GEEK CODE BLOCK[/size]
    <br />Create your own GeekCode block at: <a href="">...</a>

  3. #3

    Process Management

    Application.Terminate only terminates my application...
    Nicholas.
    <br />
    <br />Please join: http://holzstukka.proboards81.com

  4. #4
    PGD Community Manager AthenaOfDelphi's Avatar
    Join Date
    Dec 2004
    Location
    South Wales, UK
    Posts
    1,245
    Blog Entries
    2

    Process Management

    In that case, the code you saw was probably long and complicated by a requirement to obtain the necessary privileges (I think) to be able to shut down other processes.

    My question is why do you want to terminate other processes?
    :: AthenaOfDelphi :: My Blog :: My Software ::

  5. #5

    Process Management

    The JCL has code functions to terminate another process, and retrieve a list of processes if that's what you're after. I messed with it once a few years back.

  6. #6

    Re: Process Management

    Quote Originally Posted by Voltrox
    Hello,

    I have been trying to figure out how to Terminate a process in Delphi, and I saw shockingly long of code which i don't think I can remember, and i don't even understand what it means.

    Could someone please show me the simplest way (but not a bad way) in which i can terminate a process in Delphi?

    and also start processes and check to see if they are running, and how to get a list of running processes.

    Thank you.
    hello

    How to find processes and how to kill one?

    see this http://www.pscode.com/vb/scripts/Sho...=tp%2FL7562208

    greets
    Knowledge is power.

  7. #7

    Process Management

    I want to know how to terminate processes because i'm making a suspicious process monitor, which will automatically terminate malicious processes.
    Nicholas.
    <br />
    <br />Please join: http://holzstukka.proboards81.com

  8. #8
    Fran
    Guest

    Process Management

    Code:
    var
     startup&#58;_startupinfoa;
     pi&#58;_process_information;
    begin
    // Start application
     zeromemory&#40;@startup,sizeof&#40;startup&#41;&#41;;
     startup.cb&#58;=sizeof&#40;startup&#41;;
    
     createprocess&#40;nil,'program name and parameters',nil,nil,false,0,nil,nil,startup,pi&#41;;
    
    // wait program terminates
     waitforsingleobject&#40;pi.hProcess,infinite&#41;;
    To terminate a task, i suppose terminateprocess would be used. To enumerate the running tasks, i don't know... never had to use any of those 2 features. Go to http://msdn.microsoft.com/library look up terminateprocess and click on the link at the bottom of the page that lists all process functions, you should find what you're looking for there.

    ... just quickly checked, and it seems there's a function named enumprocesses... that should be what you want. As for the security thing, you likely don't have to bother with this if you're on your home machine since you should have all priviledges. If you're at work however... you might have to.

  9. #9

    Process Management

    to enumerate all running processes, use EnumProcesses in PsApi.pas....just create a big longword array (it's not predictable how many processes are running at time when you invoke it)....it will fill the array with process ids.... to obtain a handle for the process, call OpenProcess....then you can do whatever you like with the process....

  10. #10

    Process Management

    To use PSapi I would have to say "uses PSapi" ?

    but after using the EnumProcess, how do I terminate and so on?
    Nicholas.
    <br />
    <br />Please join: http://holzstukka.proboards81.com

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •