Find Process by Name
(works in: Microsoft Windows 95/98/ME/NT/2000/XP)

The FIND_PROC_BY_NAME routine lets you check whether a particular process (e.g. notepad.exe) is currently running in memory or not.

The routine is available as part of the C++ source file EXAM38.CPP. The routine has the following calling parameters:

        int FIND_PROC_BY_NAME(const char *)
where the process name is supplied as a zero-terminated C char string and it returns an integer completion code.

The return value is interpreted as follows:

       0    Specified process is not in memory
       1    Process is currently in memory

A value other 0 or 1 indicates an error condition, check the source code for details.

You can download the file in ZIP format by clicking on the following link.

This works for Microsoft Windows 95/98/ME/NT/2000/XP. I have tested with Visual C++ v6.0 but it should work with other versions also. Please let me know of exceptions.

After downloading, unzip the file Exam38.cpp into any folder. It contains a short console mode program which demonstrates how to call FIND_PROC_BY_NAME to find the NotePad program.

Change history:

  • 3/10/2002 - Fixed memory leak in some cases for Win/9x case.
  • 6/16/2003 - Removed deadwood code as pointed out by John Emmas

If you have any questions please send them to the e-mail address below.

Further Reading:

Disclaimer:
This site contains some software that I've written over the years. It is believed to work, but there is no warranty. Please use at your own risk. If you notice any bugs please let me know by email at kochhar@physiology.wisc.edu.

Return to Ravi's Free Software Page
Return to Ravi's Home Page
Back to The Basement
This page last modified on : June 16, 2003