/////////////////////////////////////////////////////////////////////////// // testApp.cpp - will become a child process spawned by spawnProc.exe // // // // Jim Fawcett, CSE687 - Object Oriented Design, Spring 2012 // /////////////////////////////////////////////////////////////////////////// #include #include #include using namespace std; int main(int argc, char *argv[]) { // get WriteHandle to pipe, passed as STD_OUTPUT_HANDLE HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE); // get Handle to screen buffer so we can write a few visible lines HANDLE console = CreateFile("CONOUT$",GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0); DWORD dwWritten; // bytes written std::string conMsg = "\n All output except for these few lines\n will be written to an anonymous pipe.\n"; WriteFile(console, conMsg.c_str(), conMsg.size(), &dwWritten, NULL); // write opening text to pipe char* msg = " Test Application:\n my arguments are:"; WriteFile(hStdout,msg,strlen(msg),&dwWritten,NULL); // write command line arguments to pipe int i; for(i=0; i