Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dual Programs? 1

Status
Not open for further replies.

Dannybe2

Programmer
Jan 31, 2001
136
GB
I have a rather difficult problem I have been struggling with for a while now.

I have two programs which need to run at the same time, but each program needs each other's objects from time to time.

So why not combine them into one big program with a launcher. Firstly I need to send a request to the launcher when the program

icon is clicked on to launch a program which I'm not really sure how to do.

Secondly, I would need to do all the threading to get the programs to run concurrently instead of letting windows do all of that

which would be a lot more simple.

Can anybody venture a solution to any part of this, or an alternative approach?

Thanks,
Dan
 
Read about CreateThread() - is it not what you are trying to do?
 
Not sure exactly what you're trying to do, so the below is a bit on the general side.

When you say "I need to send a request to the launcher when the program icon is clicked on to launch a program" do you mean that on some user action, you want to run a program?
If so, that's really quite simple - use the "exec" family of functions from the C standard library, for example (such as execl or execv)

If you really must have two separate processes talking to each other, then you need some form of Inter-Process Communication (IPC)

there are several solutions
- let the apps communicate over a socket (not very efficient, but pretty easy to do)
- use a named pipe (in windows NT, at least - Linux too, I think)
- if the processes are windows, you can use SendMessage (in the Win32 API), assuming you can get each window's handle (via FindWindow or somesuch)
- use a memory-mapped file
- use a normal file, with some manner of locking (exclusive writes, for example)

there are other types of IPC, these are just the ones that come to mind (searching for Inter Process Communication should be fruitful)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top