Getprocesses();

This is a discussion on Getprocesses(); within the C++ Programming forums, part of the General Programming Boards category; can anybody give me an example of how to list processes either using static Process* GetProcesses() []; or some other ...

  1. #1
    Unregistered
    Guest

    Getprocesses();

    can anybody give me an example of how to list processes either using static Process* GetProcesses() []; or some other method?
    i check on MSN but cant make much sense of it let alone make it work.
    thanx

  2. #2
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    AFAIK there's no win32 API function of that name. If you're using an NT based o/s then you can load EnumProcesses() from PSAPI.DLL (it's not included in any headers or libraries so you can use LoadLibrary()). Here's two links from google demostrating EnumProcesses() use -

    http://oasis2.openave.net/pub/298/3/...ocesses.h.html
    http://oasis2.openave.net/pub/298/3/...esses.cpp.html
    zen

  3. #3
    Unregistered
    Guest

    well.

    unfortunately im not on NT but thanx anyway.
    im pretty sure im not imagining it though:
    http://msdn.microsoft.com/library/de...ssestopic1.asp

    it doesnt have to be winapi.

  4. #4
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    Oh, do you mean using a 'managed C++' app with Visual Studio.NET. It looks pretty straightforward in the help files, but I wasn't able to access a Process object using managed C++ as the compiler kept telling me that it wasn't a member of the Diagnostic namespace (I was able to access it using C# though).

    If this is what you're after you may be better off finding a .NET board somewhere.
    zen

  5. #5
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    After playing about with it I've got it to work -

    Code:
    #using <mscorlib.dll>
    #using <system.dll>
    using namespace System;
    using namespace System:: Diagnostics;
    
    
    
    // This is the entry point for this application
    #ifdef _UNICODE
    int wmain(void)
    #else
    int main(void)
    #endif
    {
        //Get All Processes
    	Process* myProcess[] = Process::GetProcesses();
    	
    	//Print first 20
    	for(int i=0;i<20;i++)
    		Console::WriteLine(myProcess[i]->ProcessName);
    	
        return 0;
    }
    If you don't have a compiler that can use the managed NET extensions then you'll have to use a different method.
    zen

  6. #6
    Unregistered
    Guest
    thanx :-)
    it looks like my compiler doesnt support. ill try looking into another method.
    Thankyou for your advice, i really appreciate it :-).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. More on Processes (getProcesses)
    By P4R4N01D in forum Windows Programming
    Replies: 16
    Last Post: 04-30-2008, 04:28 AM

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