-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMain.cpp
More file actions
39 lines (31 loc) · 870 Bytes
/
Main.cpp
File metadata and controls
39 lines (31 loc) · 870 Bytes
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
// Purpose: Main program to demonstrate the use of the PipedProcess class.
#include "PipedProcess/PipedProcess.h"
#include <cassert>
#include <iostream>
#include <string>
using namespace std;
int main()
{
string buffer(1000000, 'Ö');
PipedProcess proc;
proc.SetStdInData(&buffer[0], buffer.size());
DWORD errorCode = proc.Run("DemoChildProc.exe", "");
if (errorCode == NO_ERROR)
{
cout << "DemoChildProc.exe ran successfully" << endl;
buffer = proc.FetchStdOutData();
assert(buffer.size() == 1000036);
cout << buffer.size() << " bytes received" << endl;
}
else
{
cerr << "DemoChildProc.exe failed with error code " << errorCode << endl;
}
if (proc.HasStdErrData())
{
buffer = proc.FetchStdErrData();
cerr << buffer.c_str() << endl;
assert(buffer.size() == 84);
}
return errorCode;
}