Solved

Debugging 2 MFC exes at once.

Posted on 2000-02-23
10
240 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

708 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

13 Experts available now in Live!

Get 1:1 Help Now