This sample demonstrate how to create a simple process manager.
You can find the procview sample project at:
- Start > Programs > Embarcadero RAD Studio > Samples > CPP > VCL > ProcView
- Subversion Repository for C++: http://radstudiodemos.svn.sourceforge.net/viewvc/radstudiodemos/branches/RadStudio_XE2/CPP/VCL/ProcView
This application contains a list box to display the processes, a toolbar with speed buttons to perform operations on the process list, a main menu, and a group box with radio buttons to change the display color of the process list.
How to Use the Sample
- Navigate to Start > Programs > Embarcadero RAD Studio > Samples and open procview.cbproj.
- Press F9 or choose Run > Run.
The class for the about box form.
The class for the main form.
- TFormMain, the class for the main form, handles the events that occur when interacting with the visual components on the form.
- TForm2 represents the about box displayed when the user chooses Help > About.
- The animated control is created by showing a different image after each period of time determined by the TTimer component. The images are loaded using the LoadFromResourceName method.
- EnumProc is the callback function used with EnumWindows. It receives a window handler and adds to the list box the ID of the process that created the window, the caption of the window, and the window class name.
- To kill the process selected in the list box, first its ID is retrieved by using strtok with the selected line in the list box, and then the process is killed with the TerminateProcess function.