Solved

Debugging 2 MFC exes at once.

Posted on 2000-02-23
10
241 Views
Last Modified: 2013-11-20
Hi,

I am trying to run an exe that launches another exe, but I would like to be able to debug both.? I have tried debugging the second exe (the one that is launched) and setting the first exe as the executable to run, but it still makes my break points in the second application invalid.

Cheers!

Emma
0
Comment
Question by:middlel
  • 5
  • 4
10 Comments
 
LVL 8

Expert Comment

by:VinExpert
ID: 2549644
Hi,

I dont think it is possible. If yes, then it will be a new technique for me!!!

VinExpert
0
 
LVL 4

Accepted Solution

by:
captainkirk earned 200 total points
ID: 2551119
try this:

long lRetVal = ERROR_SUCCESS;

if ((lRetVal = (long) ShellExecute(NULL, _T("open"), _T("msdev.exe"),
_T("d:\\somewhere\\YourProgram.exe"),
_T("d:\\somewhere\\"), SW_SHOW)) < 32)
{            
    CString csMsg = _T("ShellExecute() failure... check for existence of application ");
AfxMessageBox(csMsg, MB_OK | MB_TOPMOST, NULL);
} // end if



this will bring up msdev - when it does, select the build/start debug menu item for your shelled application...now you can set up breakpoints, etc....

hope that helps...
0
 

Author Comment

by:middlel
ID: 2551148
I have them both in msdev already... are you telling me to run it from the command line..?
0
 
LVL 4

Expert Comment

by:captainkirk
ID: 2551425
The first msdev runs your program which launches the second program, only instead of launching the program, it launches msdev, set to run your original second program ... now you can debug both... it requires that you substitute the above code (or a modification thereof) for the code that launches your second program...

I hope I'm understanding the problem correctly...
0
 

Author Comment

by:middlel
ID: 2553676
I like your style :-).. I'll try it and let you know.. I hope it works because it is proving very difficult to write two programs that interact so closely because you are never quite sure where the problems are..

thanks
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:middlel
ID: 2553733
Where do I put the code you mentioned? I tried launching msdev from the project settings loading up my first program which seemed to work, but I couldn't set breakpoints in the first msdev then?!?!?

thanks again..

Emma
0
 
LVL 4

Expert Comment

by:captainkirk
ID: 2555056
How and where does your first program launch the second one??? I just provided code that uses ShellExecute() - yours could be using one of the spawn functions, or even through COM/DCOM with a CoCreateInstance() call. Could you provide specifics???

0
 

Author Comment

by:middlel
ID: 2555078
My first app launches the second using CreatePRocess().
0
 
LVL 4

Expert Comment

by:captainkirk
ID: 2556032
1) try setting "msdev" as the exe to run in your CreateProcess() call and the name of your second program as a parameter to it. Of course, the second program should have been compiled in debug mode.

2) when the CreateProcess() call runs, it should bring up another copy of msdev with your second program associated with it, but not yet running.

3) now you can use the Build/Start Debug menu selection to start the second program (I recommend "Step Into" so that you can open the source file you want to set breakpoints in and then "Go".

4) Both programs are now being debugged...

0
 
LVL 4

Expert Comment

by:captainkirk
ID: 2612662
thanks, Emma - hope your project is working out OK...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Strange date stored 22 106
Get filename and folder into excel 7 68
sum13 challenge 24 90
fizzArray2 challenge 1 72
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now