Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have two programs and i want to connect them somehow. When i programmed in vb.net, i learnt this concept of moving from one form to the another through a button or something like that. I was thinking of doing the same stuff in c++. Basically,both my programs should run in a sequential manner. So, i have source.cpp and source1.cpp and i was wondering if there was a way to connect them such that when i close source.cpp then source1.cpp automatically debugs and runs. Is there a way to do that?
Posted
Updated 21-Dec-14 16:08pm
v3
Comments
George Jonsson 21-Dec-14 22:22pm    
Your terminology is a bit confusing. Do source1.cpp and source2.cpp contain a class each or do both have an entry function, main()? I.e. do you run two different applications or two classes in the same app?
Sergey Alexandrovich Kryukov 21-Dec-14 22:39pm    
"Integrating" two or more different applications is a deeply wrong way of doing "programming in large". Don't do it. What would you like to achieve with that, ultimately? If you explain your goals, we will be able to really help you.
—SA
enhzflep 21-Dec-14 22:45pm    
What's preventing you from using the same concept that you used in VB.NET, in C++?
It's a trivial matter to create a window with a button, which will trigger the creation of another window when the button is pressed.

Looks like Multi-threading will solve your problem. Plainly it means running more than one instances of code.

A simple Example from Microsoft.

To interact between the threads you can use events.
 
Share this answer
 
Key features:

1. "both my programs should run in a sequential manner."
2. "when i close source.cpp then source1.cpp automatically debugs and runs."

Multithreading won't help here. I'll ignore the "debugs" in your request and assuming you really just want the second program to execute. I assume the two programs are named source.exe and source1.exe.

Use a command file.

https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/start.mspx?mfr=true

Create a command file. We'll call it two.cmd:

start /wait \path\to\source.exe
start /wait \path\to\source1.exe


The advantage is you do not need to modify either program. This isn't limited to Windows. You can do the same from a bash script too.

. /path/to/source
. /path/to/source1
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900