• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 203
  • Last Modified:

Process Running ?

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
gnow
Asked:
gnow
1 Solution
 
nietodCommented:
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
 
jkrCommented:
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
 
MikeP090797Commented:
If you have the name of the window caption, or it's class name, you can use FindWindow, and then GetWindowThreadProcessID
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
gnowAuthor Commented:
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
 
nietodCommented:
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
 
nietodCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now