1

我有一个命名管道,当我使用在我的系统上运行的客户端访问它时,它工作正常

客户端尝试使用以下代码打开文件:

LPTSTR lpszPipename = TEXT("\\\\smyServerName\\pipe\\iPipe01"); 

      hPipe = CreateFile( 
         lpszPipename,   // pipe name 
         GENERIC_READ |  // read and write access 
         GENERIC_WRITE, 
         0,              // no sharing 
         NULL,           // default security attributes
         OPEN_EXISTING,  // opens existing pipe 
         0,              // default attributes 
         NULL);     


      if (hPipe != INVALID_HANDLE_VALUE) 
         break; 

      // Exit if an error other than ERROR_PIPE_BUSY occurs. 

      if (GetLastError() != ERROR_PIPE_BUSY) 
      {
         _tprintf( TEXT("Could not open pipe. GLE=%d\n"), GetLastError() ); 
         return -1;
      }

在创建我使用过的命名管道时

lpszPipename = TEXT("\\\\.\\pipe\\iPipe01"); 

而不是myServerName我用过.(Dot)。当我从另一个系统运行客户端时,我得到 GLE 5(拒绝访问)。

4

2 回答 2

1

首先要做的事情 - 检查您的权限和防火墙。几乎总是,当某些东西在本地工作但不在网络上时,它就是权限。

(遇到这个问题的次数我数不过来!)

于 2010-09-08T11:27:58.127 回答
1

AFAIR there was a change of security of anonymous access to named pipes in Windows Vista.
When you want to open it (with write access) from the anonymous account, you may have to change the pipe's security attributes as described here.

于 2010-09-08T12:42:08.357 回答