Solved

Debugging 2 MFC exes at once.

Posted on 2000-02-23
10
243 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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
 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
List out all word 7 316
substring method in java 1 129
Annoying "thing" blocks my view 4 113
How do I get Window Title of all opened process? 4 11
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

790 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