我在C++中创建管道,当我尝试使用php代码写入该管道时,当我尝试获取该管道的句柄时,它给了我访问拒绝错误。 基本上,PHP代码调用另一个C++ EXE写入管道,但它失败。我认为它死了一些安全或访问权限,用户没有(PHP用户)。 任何想法??在C++和php中命名管道
码C++
hPipe = CreateNamedPipe(
wcPipeName, // pipe name
PIPE_ACCESS_DUPLEX, // read/write access
PIPE_TYPE_MESSAGE | // message type pipe
PIPE_READMODE_MESSAGE | // message-read mode
PIPE_WAIT, // blocking mode
PIPE_UNLIMITED_INSTANCES, // max. instances
1024, // output buffer size
1024, // input buffer size
NMPWAIT_USE_DEFAULT_WAIT, // client time-out
NULL);
代码客户端从PHP
hPipe = CreateFile(
lpszPipename, // pipe name
GENERIC_READ, // read and write access
0, // no sharing
NULL, // default security attributes
OPEN_EXISTING, // opens existing pipe
0, // default attributes
NULL); // no template file
if (hPipe == INVALID_HANDLE_VALUE)
{
printf("\nCreatePipe failed\n %d \n",GetLastError());
return FALSE;
}
//Sleep(1000);
// Write the reply to the pipe.
fSuccess = WriteFile(
hPipe, // handle to pipe
Buffer, // buffer to write from
BufferSize-1, // number of bytes to write
&cbWritten, // number of bytes written
NULL); // not overlapped I/O
FlushFileBuffers(hPipe);
CloseHandle(hPipe);
我有一个想法:发布一些代码。 :) – netcoder 2012-02-15 20:20:31
你可以发布客户端和服务器的C++代码,并在什么平台上运行?这两个进程是否以相同的用户身份运行? – hmjd 2012-02-15 20:22:38
没有php代码正在运行,因为iis用户 – kunal 2012-02-15 20:26:14