1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

how get name of process in c/c++

Discussion in 'C' started by p d, Nov 16, 2011.

  1. p d

    p d New Member

    Joined:
    Apr 16, 2010
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    hi...
    how get name of process and kill once ...
    i do it in c# , but i need c++ codes.
    thx for your helpping
     
  2. poornaMoksha

    poornaMoksha New Member

    Joined:
    Jan 29, 2011
    Messages:
    150
    Likes Received:
    33
    Trophy Points:
    0
    Occupation:
    Software developer
    Location:
    India
    Since you have not mentioned the OS, so I assume the OS to be Linux.

    You should know the PID of the process and then replace the PID in the path

    /proc/PID/cmdline

    Open the following file and you will get the name of the process and the arguments passed to it.
     
  3. p d

    p d New Member

    Joined:
    Apr 16, 2010
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    thx...
    no in widows.
    look this :
    Code:
    #include "conio.h"
    #include <iostream>
    int main()
    { int i=system("tasklist");
        
        printf("%s",i);
        getch();
    return 0;
    } 
    but it is'not useful; because i need array of process name for process
     
  4. poornaMoksha

    poornaMoksha New Member

    Joined:
    Jan 29, 2011
    Messages:
    150
    Likes Received:
    33
    Trophy Points:
    0
    Occupation:
    Software developer
    Location:
    India
  5. p d

    p d New Member

    Joined:
    Apr 16, 2010
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    thx.
    ok . find it at last .
    TerminateProcess(OpenProcess(PROCESS_TERMINATE,FALSE,PID),0) //Where PID is a int (or UNIT)
    ---
    now i need too PID number... how get it ?
    for example yahoo in my pc is 5328, and chang if closed ; but how the program find it ?
     
  6. p d

    p d New Member

    Joined:
    Apr 16, 2010
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    i find it :D:D
    thx for all ...
    gooooooooood look!
     

Share This Page