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

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

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(访问拒绝)。

有帮助吗?

解决方案

首先,请检查您的权限和防火墙。几乎总是,当某些东西在本地工作但不在网络上时,这是权限。

(这个问题的次数超过了我的数量!)

其他提示

AFAIR改变了Windows Vista中对命名管的匿名访问的安全性。
当您想从匿名帐户打开它(使用写入访问)时,您可能必须如上所述更改管道的安全属性 这里.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top