我想在托管和非托管过程之间做一些IPC。我已经解决了命名管道问题。CallNamedPipe&NamedPipeServerStream,访问被拒绝?
我纺一个线程在托管代码,使用NamedPipeServerStream:
using (NamedPipeServerStream stream = new NamedPipeServerStream("MyPipe", PipeDirection.In))
{
while (true)
{
stream.WaitForConnection();
stream.Read(buffer, 0, size);
//Handle buffer values
}
}
在非托管端我使用CallNamedPipe:
CallNamedPipe(TEXT("\\\\.\\pipe\\MyPipe"), NULL, 0, pData, dataSize, NULL, NMPWAIT_WAIT_FOREVER);
但是,CallNamedPipe失败的GetLastError函数5(拒绝访问)。任何想法为什么?
出于测试目的,我试着在相同的过程中运行两个代码路径,达到相同的效果。无论如何,我会研究PipeSecurity。 – 2009-07-24 01:10:33