c+中的命名管道+;和php 我在C++中创建一个管道,当我尝试用PHP代码写那个管道时,当我试图得到那个管道的句柄时,它会给我一个访问拒绝的错误。 基本上PHP代码调用另一个C++ exe,它写在管道上,但失败了。我想它会死在用户没有的安全或访问权限(PHP用户)上。 有什么想法吗 代码C++ +/P> 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);

c+中的命名管道+;和php 我在C++中创建一个管道,当我尝试用PHP代码写那个管道时,当我试图得到那个管道的句柄时,它会给我一个访问拒绝的错误。 基本上PHP代码调用另一个C++ exe,它写在管道上,但失败了。我想它会死在用户没有的安全或访问权限(PHP用户)上。 有什么想法吗 代码C++ +/P> 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,c++,ipc,named-pipes,Php,C++,Ipc,Named Pipes,从php调用用于编写的代码客户端 hPipe = CreateFile( lpszPipename, // pipe name GENERIC_READ, // read and write access 0, // no sharing NULL, // default security attributes OPEN_EXISTING, // ope

从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);

由于服务器和客户端进程在两个不同的用户帐户下运行,并且服务器端管道是使用默认安全描述符创建的,因此建议设置一个允许
所有人
访问的安全描述符:

// Create a security descriptor that has an an empty DACL to
// grant access to 'Everyone'
//
SECURITY_DESCRIPTOR sd;
if (0 == InitializeSecurityDescriptor(&sd,
                                      SECURITY_DESCRIPTOR_REVISION) ||
    0 == SetSecurityDescriptorDacl(&sd,
                                   TRUE,
                                   static_cast<PACL>(0),
                                   FALSE))
{
    std::cerr << "Failed: " << GetLastError() << "\n";
}
else
{

    SECURITY_ATTRIBUTES sa;
    sa.nLength              = sizeof(sa);
    sa.lpSecurityDescriptor = &sd;
    sa.bInheritHandle       = FALSE;

    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 
        &sa); 
}
//创建一个具有空DACL的安全描述符
//授予对“所有人”的访问权限
//
安全描述符sd;
如果(0==初始化安全描述符(&sd),
安全性(描述符(修订版)||
0==SetSecurityDescriptorDacl(&sd),
是的,
静态_-cast(0),
假的)
{

STR::我有一个想法:发布一些代码。):你可以发布客户端和服务器C++代码,以及在这个平台上运行什么?这两个进程是作为同一个用户运行的吗?没有PHP代码运行,因为IIS用户发布了代码。