Operating Two programs within same program

Hello every one
Is it posible to operate two programs within same program??
for example I have a program of competition and I want to add counter of time for answering and the program should allow the user to select answer when the counter is operated.

I'm really waiting for your reply

With all respect to all
Yes you can control two programs from one program. You'll need to setup a communication method between the two programs

Here are a couple of ideas
1) File - share a file between programs and use a mutex for managing the writes

2) DDE - Dynamic Data Exchange

3) Shared memory map - pass data between shared map

4) Sockets - use tcp/ip sockets to pass data if same computer then use localhost for ip address or the 127.0.0.1 loop back

5) Registry - use registry enties to pass info

These are just a couple of methods there are many other ways to communication between two programs.
The other approach is to use multi-threading, where you have a single program that perfroms two (or more) tasks simultaneously.

There is a post in the Articles Forum that mentions this, and has a link to a set of libraries to make this a little easier.
http://www.cplusplus.com/forum/articles/2145/

I can't comment on how difficult muti-threading is in C++, as it's not something I've tried, but in Delphi (pascal based) it's certainly something you do with care, lots of thinking and planning before writing code!
The way I see it you have two choices, the threading option as suggested by Faldrax which is effectively multiple programs running within a single process but sharing resources like memory, or two separate programs using some form of interprocess communication. The options on this second one depend on the platform, Unix provides different options to Microsoft for example, (dboyce's list appears to be Microsoft) although there are some that are common. Shared memory, pipes and sockets for example are common to both Windows and Unix.
Topic archived. No new replies allowed.