0

I want a create a C++ program that can find an already running process and then redirect its Standard Output to my own stream for re-direction. I can find countless examples on how to start a new process but I want to try and do something like:

Process^ proc = new Process();
proc->Attach("notepad.exe");

And then have control over the already running notepad.exe process.. Is this possible? If not then I guess I can find a way to start the process from within my application, however then my question would be how can I start a process and send command-line arguments to the process as if I were starting it up in console.

Oliver Charlesworth
  • 260,367
  • 30
  • 546
  • 667
Matt Hintzke
  • 7,305
  • 15
  • 50
  • 110

1 Answers1

1

I believe you want GetProcessesByName. It will return an array of all the processes that match the name you give.

array<Process^>^ notepadProcesses = Process::GetProcessesByName("notepad");
David Yaw
  • 26,633
  • 4
  • 60
  • 91