Repository navigation
Expand file tree
/
Copy pathmain.cpp
More file actions
70 lines (54 loc) · 1.74 KB
/
Copy pathmain.cpp
File metadata and controls
70 lines (54 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* /////////////////////////////////////////////////////////////////////////
* File: by_library/toolhelp/process_sequence/process_sequence.cpp
*
* Purpose: C++ example program demonstrating use of the ToolHelp library.
*
* Created: 22nd May 2006
* Updated: 9th October 2024
*
* ////////////////////////////////////////////////////////////////////// */
/* WinSTL header files */
#include <winstl/toolhelp/process_sequence.hpp>
/* Standard C++ header files */
#include <exception>
#include <iostream>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;
/* Standard C header files */
#include <stdlib.h> // for EXIT_FAILURE, EXIT_SUCCESS
/* /////////////////////////////////////////////////////////////////////////
* main()
*/
int main()
{
try
{
// 1. Construct an instance of process_sequence. There is no parameter
// required for process_sequence.
winstl::process_sequence processes;
// 2. Declare iterator instances (since we're using a manual loop,
// rather than an algorithm).
winstl::process_sequence::const_iterator b = processes.begin();
winstl::process_sequence::const_iterator e = processes.end();
// 3. Loop through the range.
for (; b != e; ++b)
{
// 3.1. Print out the process id and the file name.
cout << (*b).th32ProcessID << ": " << (*b).szExeFile << endl;
}
return EXIT_SUCCESS;
}
catch (std::exception& x)
{
cerr << "Error: " << x.what() << endl;
return EXIT_FAILURE;
}
catch (...)
{
cerr << "Unknown error" << endl;
return EXIT_FAILURE;
}
}
/* ///////////////////////////// end of file //////////////////////////// */