Way to get the current open programs displayed?

This is a discussion on Way to get the current open programs displayed? within the C++ Programming forums, part of the General Programming Boards category; In a win32 console program, is there a way to get the current open programs displayed (Not to a message ...

  1. #1
    Registered User
    Join Date
    Jun 2005
    Posts
    8

    Way to get the current open programs displayed?

    In a win32 console program, is there a way to get the current open programs displayed (Not to a message box, but to the console) ?

    I am making a little log program that will log information like open connections to a log file (report.log) by using a batch file. For instance there is netstat >>report.log in the batch file. I want to make a program that displays the programs that are open (You know, like when you press control + alt +del it shows the open programs?) so I can put that in a log.

    I guess what im looking for is something similar to Unix's command PS,
    but I will settle for something easier like just displayin the program names open

    Functions or code snippits appreciated. Thanks!
    Last edited by CPPguy1111; 06-18-2005 at 05:09 AM.

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    On Windows XP, you can use the tasklist console command. Also, have a look at the Enumerating All Processes code sample.

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    8
    Quote Originally Posted by anonytmouse
    On Windows XP, you can use the tasklist console command. Also, have a look at the Enumerating All Processes code sample.
    Ok, I dont have Windows XP, and the code provided by the Microsoft website requires the .net framework. I tried compiling it with borland C++ (I know ewww.), then with microsoft visual C++ 6.0, and nothing. Says im missing a file called PSAPI.H, where can I find it, and if I can, can I even use it with visual C++ ?

  4. #4
    x4000 Ruski's Avatar
    Join Date
    Jun 2002
    Location
    Outer Space!
    Posts
    542
    Umm.. tasklist didn't work.. I'm using windows xp sp1 home edition.. I typed in tasklist in console and it just said that function or file not found (or whatever he says there...) What's the problem? Is this the same thing I had with irftp? I couldnt manage to run that either before I downloaded irftp.exe from the net and put it in my windows directory
    what does signature stand for?

  5. #5
    Registered User
    Join Date
    Jun 2005
    Posts
    8
    There is a program (set of small console apps) called UnixDos, which has several unix type commands. PS is one of them, it lists the processes, and you can >> it to a file if you want. However, this is shareware, and expires in 30 days, and I don't feel like shelling out cash for something I 'could' program myself.

    As I said above, the program code that is provided on the microsoft website doesnt work without PSAPI.H, and probably a few other headers or whatever that PSAPI.H requires, so I am at a loss with that one.

    Someone sent me this link in my mailbox:
    process IDīs

    So I tried to compile the code, and after figuring out I needed iostream.h declared first, I got it down to 3 errors

    C:\Progra....proc.cpp(12) : error C2065: 'TH32CS_SNAPPROC' : undeclared identifier
    C:\Progra...proc.cpp(12) : error C2146: syntax error : missing ')' before identifier 'ESS'
    C:\Progra...proc.cpp(12) : error C2059: syntax error : ')'

    And since I dont have a clue what TH32CS_SNAPPROC is, I am lost with this one as well.

    Can anyone help with this, or let me know how I can use PSAPI?

    I have microsoft visual C++, and also borland C++ 5.02

  6. #6
    *this
    Join Date
    Mar 2005
    Posts
    498
    9th line should be:

    (TH32CS_SNAPPROCESS|TH32CS_SNAPTHREAD, 0);

  7. #7
    *this
    Join Date
    Mar 2005
    Posts
    498
    ^^^ see the no spaces part, the spaces was a bug in code display on the forums

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Immediate programming help! Please!
    By xMEGANx in forum C++ Programming
    Replies: 6
    Last Post: 02-20-2008, 12:52 PM
  2. compiler build error
    By KristTlove in forum C++ Programming
    Replies: 2
    Last Post: 11-30-2003, 10:16 AM
  3. linked list recursive function spaghetti
    By ... in forum C++ Programming
    Replies: 4
    Last Post: 09-02-2003, 03:53 PM
  4. HelpMePlease
    By Prncess100 in forum C++ Programming
    Replies: 6
    Last Post: 12-11-2002, 02:02 PM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 02:27 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21