How to Find PID
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: How to Find PID

  1. #1
    Join Date
    May 2007
    Posts
    134

    How to Find PID

    Hi

    I am opening the 3 note pad and the three process are running in task bar
    i.e notepad.exe(3), so i want to get the pid of second note pad and kill that processs manually.

    I don't want to kill another two process those are running in task bar i.e notepad1 and notepad3 these are remine run in task bar only that notepad2 is kill

    please suggest me How will i kill this one programmtically.


    Thanks
    Anand

  2. #2
    Join Date
    May 2007
    Posts
    437

    Re: How to Find PID

    Quote Originally Posted by anandtugaon
    Hi

    I am opening the 3 note pad and the three process are running in task bar
    i.e notepad.exe(3), so i want to get the pid of second note pad and kill that processs manually.

    I don't want to kill another two process those are running in task bar i.e notepad1 and notepad3 these are remine run in task bar only that notepad2 is kill

    please suggest me How will i kill this one programmtically.


    Thanks
    Anand
    have a look process

    ashu
    always use code tag

  3. #3
    Join Date
    Aug 1999
    Location
    <Classified>
    Posts
    6,882

    Re: How to Find PID

    Adding to what Ashish wrote, you can use TerminateProcess API to end it.
    Regards,
    Ramkrishna Pawar

  4. #4
    Join Date
    May 2007
    Posts
    134

    Re: How to Find PID

    Hi krishanna,


    I knew we can use these API's to kill process

    1)EnumProcesses
    2)OpenProcess
    3)EnumProcessModules
    4)GetModuleBaseName
    5)TerminateProcess

    I am asking, I am opening 3 notepad, i it will create three running notepad.exe, i want to kill second notepad.exe i wont to kill another two notepad.exe( i. e 1st and 3rd ).

    using this we can kill all three notepad.exe

    So my main question is, How to kill 2nd notepad.exe ?

  5. #5
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,039

    Re: How to Find PID

    Well, I cannot see what's the difference between 1st and 2nd Notepads? The time of appearing? Then you run your program in background and register new Notepad appearing. In case it's a third one, you already have PID1 and PID2. You enumerate top windows, find out the one that belongs to PID2 process and post WM_CLOSE to it. After closing the PID3 becomes PID2, and from this moment it is the first candidate for closing.

    Easy thing...
    Best regards,
    Igor

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center