I'm trying to do some IPC between a managed and unmanaged process. I've settled on named pipes.
I'm spinning up a thread in managed code, using NamedPipeServerStream:
using (NamedPipeServerStream stream = new NamedPipeServerStream("MyPipe", PipeDirection.In))
{
while (true)
{
stream.WaitForConnection();
stream.Read(buffer, 0, size);
//Handle buffer values
}
}
On the unmanaged side I'm using CallNamedPipe:
CallNamedPipe(TEXT("\\\\.\\pipe\\MyPipe"), NULL, 0, pData, dataSize, NULL, NMPWAIT_WAIT_FOREVER);
However, CallNamedPipe fails with a GetLastError of 5 (Access Denied). Any idea why?