Solved

Process Running ?

Posted on 1998-12-04
6
195 Views
Last Modified: 2010-04-02
Is there a function in NT which returns the ProcessId
of a Process, if I only know the process-name ? What
am I looking for is something like this:

pid = processId ( "NameOfTheProcess" );
0
Comment
Question by:gnow
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 1179196
Processes don't have names.  What information do you have about the process?  Did your program start the process?  Do you know anything about windows the process creates, if any?
0
 
LVL 86

Expert Comment

by:jkr
ID: 1179197
You could use the functions provided with 'psapi.dll' to achieve this - sorry, but as i'm at home now, you'll have to wait for an example 'til tomorrow ;-)
0
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1179198
If you have the name of the window caption, or it's class name, you can use FindWindow, and then GetWindowThreadProcessID
0
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 

Author Comment

by:gnow
ID: 1179199
That's my problem. The process are started in a command prompt and started during startup of NT.

My goal is to generate a watchdog-process, which is checking several processes
from time to time if they are still running. If not, it should restart these processes. Due
to I don't want any interprocess-communication I need something indepandent from
the other processes.

It could be that my idea is wrong and I have to go a different way. Has anybody
expirience in doing this ? Is it better to start the processes as a service and then
have a "watchdog-service" check the other services ?

0
 
LVL 22

Accepted Solution

by:
nietod earned 50 total points
ID: 1179200
I think you can use EnumProcesses() to enumerate all the processes.  Then use GetModuleFileNameEx() for each processed to get the path and file name of the executable.  
0
 
LVL 22

Expert Comment

by:nietod
ID: 1179201
Opps.  Missed one thing.  To enumerate 16 bit processes in NT you must use VDMEnumTaskWOWEx().  This will save you from having to use GetModuleFilenameEx() as the callback routine will be passed the executable's path and file name.

Look up article Q175030 in the MS knowledgebase.  It describes the details.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question