Createpipe (& m_hread, & m_hwrite, & SA, 0) creates an anonymous Pipeline
CreateProcess (".. // child // debug // child.exe", null, true,
0, null, null, & Sui, & PI) Pass the anonymous pipeline read and write handle of the parent process to Sui. hstdinput = m_hread through the startupinfo structure Sui;
Sui. hstdoutput = m_hwrite;
Similarly, read and write data from the pipeline through readfile and writefile
Named Pipe
Server:
Hpipe = createnamedpipe ("//. // pipe // mypipe ",
Pipe_access_duplex | file_flag_overlapped,
0, 1, 0, null); // create a named pipe
Handle hevent;
Hevent = createevent (null, true, false, null );
Overlapped ovlap;
Zeromemory (& ovlap, sizeof (overlapped ));
Ovlap. hevent = hevent;
Connectnamedpipe (hpipe, & ovlap) // wait for the client to connect
Waitforsingleobject (hevent, infinite) // wait for the event to occur
Then read data from the pipeline through readfile and writefile
Client:
Waitnamedpipe ("//. // pipe // mypipe", nmpwait_wait_forever) // connect to the MPs queue
Hpipe = createfile ("//. // pipe // mypipe", generic_read | generic_write,
0, null, open_existing, file_attribute_normal, null); // open an existing pipeline
Then read data from the pipeline through readfile and writefile
The server side of the oil tank can only receive data, and the client can only send data. Because it is based on the broadcast communication system, the oil tank can be used, encode multiple servers and one client to implement a one-to-many network system.
Server:
Handle hmailslot = createmailslot ("//. // Mailslot // mymailslot", 0,
Mailslot_wait_forever, null); // create a tank
Readfile (hmailslot, Buf, 100, & dwread, null) // read data
Client:
Hmailslot = createfile ("//. // Mailslot // mymailslot", generic_write, file_assist_read,
Null, open_existing, file_attribute_normal, null); // open the Oil Tank
Writefile (hmailslot, Buf, strlen (BUF) + 1, & dwwrite, null) // write data
The clipboard and anonymous pipeline can only communicate between two processes on the same machine, but cannot communicate across networks. The named pipeline and the oil tank can both, you can also implement one-to-many communication for the oil tank, while the named pipe can only be a point-to-point communication. However, the number of messages sent in the tank is less than 424 bytes.