Launch external application from C++ program and attach it to visual 2008 debugger while debugging host in WinAPI
- by PiotrK
Basically I have Host and Child program. I do not have sources for Child so I can't change anything in it. I want to launch Host from debugger, which at some point should launch Child program. I want to attach Child automatically for debugging session as well (so any breakpoints set in DLL sources loaded under Child process will hit).
How to do this in Visual Studio 2008 C++ with standard WinAPI?
I tried this:
SHELLEXECUTEINFO sei = {0};
sei.cbSize = sizeof (SHELLEXECUTEINFO);
sei.fMask = SEE_MASK_NOCLOSEPROCESS;
sei.lpVerb = "open";
sei.lpFile = "Child.exe";
sei.lpParameters = "/Param";
sei.nShow = SW_SHOWNORMAL;
if (ShellExecuteEx (&sei))
{
WaitForSingleObject (sei.hProcess, INFINITE);
}
But this does not attach debugger for Child.exe