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
  • 267,707
  • 33
  • 569
  • 680
Matt Hintzke
  • 7,744
  • 16
  • 55
  • 113

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
  • 27,383
  • 4
  • 60
  • 93