Jump to content
  • Advertisement
Sign in to follow this  
sadface42

Getting a process ID (And using the MSDN)

This topic is 4438 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am a student programmer and I always have difficulty in using the MSDN library to find functions that I dont know the name of. I currently am looking for a function (or set of functions) which will give me the ID of a process given it's name (ie. the name that appears in the list of running processes when you press ctrl+alt+del in Windows XP. Note that this is different from the name of the window it's attached to or I might use FindWindow followed by GetWindowThreadProcessId). I was wondering if someone might explain to me how to do this, as well as any tricks that they might know on how to go about finding this sort of information in the future. Thanks!

Share this post


Link to post
Share on other sites
Advertisement
EnumProcesses
Example: Enumerating All Processes

As for how to locate such functions, the MSDN documentation on the Win32 API and Platform SDK is structured hierarchically. The EnumProcesses API was located under Win32 and COM Development > System Services > DLLs, Processes and Threads > SDK Documentation > DLLs, Processes and Threads > Process Status API (PSAPI) > PSAPI Reference > PSAPI Functions > EnumProcesses. With time you get a feel for where things should be in the API, so just scan those sections.

Share this post


Link to post
Share on other sites
If you're given a name from the Applications tab in Ctrl-Alt-Del then there is no way to get the process ID. That name could come from various places, including FindWindow(). If you have the exe file name then you can use CreateToolhelp32Snapshot() and then Process32First() and Process32Next().

As for finding things in the MSDN, it helps to just use it a lot. The more you use it the more you start to figure out how it's organized. Using it more will also allow you to learn more functions so that you can search for them the next time you need to get back to that section.

Share this post


Link to post
Share on other sites
Quote:
Original post by Colin Jeanne
That name could come from various places, including FindWindow().

Correct me if I'm wrong, but the entry in the application list is always equivalent to a specific window's title... Perhaps I misunderstood something?

Share this post


Link to post
Share on other sites
Quote:
Original post by raz0r
Quote:
Original post by Colin Jeanne
That name could come from various places, including FindWindow().

Correct me if I'm wrong, but the entry in the application list is always equivalent to a specific window's title... Perhaps I misunderstood something?

The application list is irrelevant. Look at the process list. You'll quickly see that the application list entires correspond to the window caption for the processes that create and display windows - but most of them don't.

The process list entries correspond to the names of the actual binaries being executed, except for system services which rely on SVCHOST.EXE.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!