August 20, 2009
Communicating between processes with Pipe
Instead of using a complicated Sendmessge between processes, there is another convenient way to communicate between processes. Pipe!
There is a good tutorial and implementation demo with C#. link
I just used the server client in my program. But for the client, I used a simple C++ implementation.
HANDLE h=NULL;
void send_message(char *msg)
{
if (!h)
{
h=CreateFile(L"\\\\.\\pipe\\MyNamedPip",
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
NULL);
}
DWORD BytesWritten;
WriteFile(h,msg,strlen(msg),&BytesWritten,NULL);
FlushFileBuffers(h);
}
Comments(0)
