Click here to Skip to main content
14,932,010 members
Articles / Programming Languages / C++/CLI
Posted 4 Jan 2004


13 bookmarked

How to use Process Class in Managed C++

Rate me:
Please Sign up or sign in to vote.
3.50/5 (9 votes)
4 Jan 20042 min read
This article explains how to use Process Class in Managed C++ applications


The simplest definition of Process is executing instance of an application. The process contains at least one thread. The thread is a fundamental unit of the operating system. Windows is a multitasking operating system. Every process contains at least one thread. Windows NT family system and Windows 95/98 based system support preemptive multitasking. So, we can work freely for multiple threads and multiple processors.

Process Class

In Microsoft .NET framework all the namespaces derived from Object. The System.Diagnostics namespace provides the information about the process state, start the new process, etc. In this namespace allows to starts the new process, kill process, etc.

In process class allows to monitor local system process information or remote system process information. We also interact with the ProcessThread and ProcessModule classes. The ProcessStartup class provides the arguments passing and etc. ProcessStartInfo Constructor use to initializes the process information.

ProcessStartInfo contains the following properties.


The arguments property use to set the argument in file name like ShellExecute function.


The FileName Property is used to set the application name . We can set this property before starting the process class.


If we set this is True we can perform the file operations (like, printing the contents in that file). If we set False we just execute the application.


We set and get the WindowStyle in process starting time.


WaitForExit property is to wait for the process fora specified time.

For Example :-

Notepad->waitForExit(1000) // waits 1000 seconds.


Kill property is to kill the currently running process.

Ex :-  notePad->Kill();

The following code is to start the notepad. It waits 1000 secounds and kills it automatically using kill property in Process class.

// Create Process

Process *notePad = new Process();

// set the filename
notePad->StartInfo->FileName   = "notepad.exe";

// Arguments
notePad->StartInfo->Arguments = "textfile.txt";

//Start the process

// Wait for 1000 secounds

//Kill the process

Process Thread Class

The Process Thread contains information about the currently running process. We control the threads within the process. We set or get the thread proprieties like low, high. The Process Thread class contains the following properties.


The BasePrority is used to get the priority.


The CurrentPriority Class is to get the current priority


The PriorityLevel is to Get or set the priority level


The ThreadState is to get the current state

ProcessModule class

The ProcessModule class is to get the information about the process module. In ProcessModule class, properties are used to get the information like get module name, memory size in the module, etc.

The following code explains the use of ProcessModule class to get module name, fileinfo etc.

// Create process
Process *notePad = new Process();

// set filename
notePad->StartInfo->FileName   = "notepad.exe";

notePad->StartInfo->Arguments = "selvam.txt";



//Create processmodule class
ProcessModule *myProcessModule;
myProcessModule = notePad->MainModule;

String *strFileName, *strModuleName;
int nMemory;

//Get the process file name, Module name etc..
strFileName = myProcessModule->FileName;
strModuleName = myProcessModule->ModuleName;
nMemory = myProcessModule->ModuleMemorySize;


The .NET framework is used to simplify the programming model. So, we can easily interact with the operating system. The Process class is useful to start the new process, stop the existing process and control the process. ProcessModule class is used to get the module information in the running application.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Selvam R
India India
Selvam has worked on several technologies like Java, Python, Big data, VC++, MFC, Windows API and Weblogic server. He takes a lot of interest in reading technical articles and enjoys writing them too. He has been awarded as a Microsoft Community Star in 2004, MVP in 2005-06, SCJP 5.0 in 2009, Microsoft Community Contributor(MCC) 2011.

Big Data
o Google Professional Data Engineer 2021
o Confluent Certified Developer for Apache Kafka 2020
o Datastax Apache Cassandra 3.x Developer Associate Certification 2020
✓ Cloud
o Google Professional Cloud Architect 2021
o Microsoft Certified: Azure Solutions Architect Expert 2020
o AWS Certified Solutions Architect - Associate 2020
✓ Oracle Certified Master, Java EE 6 Enterprise Architect (OCMEA) 2018

Github :
Web site:

Comments and Discussions

GeneralAnd Application Pin
Rodolfo Huper29-Mar-05 6:04
MemberRodolfo Huper29-Mar-05 6:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.