Blog

Caption of a Running processes

Posted by Mayur Dighe Blogs | Visual C# Sep 02, 2012
The Blog demonstrate a method to obtain the caption of a main window of currently running processes.
Download Files: ProcessTitle.zip

Description

 About Classes used

#1: Process class, provides an access to local & remote processes, also enable to start & stop  

Local system processes. Using the Process component, we can obtain a list of the

processes that are running, or can start a new process.

Namespace Required - System. Diagnostics

Here I implemented the Code for obtaining Caption of main window of the running processes.

The Code

1. Access the Running Processes (code for “Refresh” Button).

//Access all the running processes
      foreach (Process var in Process.GetProcesses())
            {
                  try
                  {     //if Caption if NOT Blank then
                        //Add Caption of Process to ListBox
                        if (var.MainWindowTitle != "")
                              listBox1.Items.Add(var.MainWindowTitle);
                  }
                  catch (Exception) { //Add code for Exception (if any) }
            }

Listing 1

2. Now you can pass this Process Caption to any other control. (Here I used it for a ListBox Control)

3. Now execute the Application and see the result (Figure 1).         

Intended Result

New Picture.png

Figure 1

Summary:
          
In this piece of writing, using C# environment, we have seen how to retrieve the caption/title of a main window of the running processes on the local system.

post comment
     
COMMENT USING
PREMIUM SPONSORS
DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and add new content to existing PDF documents from within your applications.
Join a Chapter
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Get Career Advice from Experts