Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IPC between Processes with ShellExecute

Tags:

c++

pipe

winapi

ipc

I'm working in the win32 api in C++. I have a parent process, and I'm using it to run a new program through a call to ShellExecute.

I'd like for the child process to be able to talk to the parent process (Communication only needs to go one way). I think an anonymous pipe would be suitable for this, and I've found how to create the pipe using the CreatePipe function, but I'm unsure of how to give the pipe to the child process using the ShellExecute command.

Could anyone point out a decent/relevant tutorial on this? Or, if another form of IPC works better than pipes, please point me in that direction.

In case its relevant, this is what my shell execute command looks like:

ShellExecute(NULL, "open", "Argo\\argo.exe", NULL, NULL, 1);
like image 654
keefertaylor Avatar asked Jan 23 '12 05:01

keefertaylor


1 Answers

All things being equal, Windows "named pipes" might be an ideal way to go:

http://msdn.microsoft.com/en-us/library/windows/desktop/aa365590%28v=vs.85%29.aspx

Using a named pipe completely eliminates the need to pass ANYTHING between parent and child: the parent opens for reading, the child opens for writing whenever it needs to, everything's synchronized without any extra work.

like image 175
paulsm4 Avatar answered Sep 20 '22 00:09

paulsm4