HANDLE WINAPI CreateNamedPipe(
  __in      LPCTSTR lpName,
  __in      DWORD dwOpenMode,
  __in      DWORD dwPipeMode,
  __in      DWORD nMaxInstances,
  __in      DWORD nOutBufferSize,
  __in      DWORD nInBufferSize,
  __in      DWORD nDefaultTimeOut,
  __in_opt  LPSECURITY_ATTRIBUTES lpSecurityAttributes
);请问第四个参数 nMaxInstances 是什么意思呢?我查看了MSDN了,说的是管道的实例数目。但实例,具体指的是什么呢?是允许连接的程序的数目还是说别的意思呢。谢谢。

解决方案 »

  1.   

    nMaxInstances 
    The maximum number of instances that can be created for this pipe. The first instance of the pipe can specify this value; the same number must be specified for other instances of the pipe. Acceptable values are in the range 1 through PIPE_UNLIMITED_INSTANCES (255). If this parameter is PIPE_UNLIMITED_INSTANCES, the number of pipe instances that can be created is limited only by the availability of system resources. If nMaxInstances is greater than PIPE_UNLIMITED_INSTANCES, the return value is ERROR_INVALID_PARAMETER.
      

  2.   

    回复楼上,
    我已经说过了,我已经查看了MSDN的文档了。然而我不理解的是,他当中 Instance(实例)所指代的是什么东西。一个管道的实例到底是什么概念。
      

  3.   

    做了一系列的实验 自己搞明白了这里实例的含义了。在windows底下 进程之间可以进行管道通信。其中在不相干的进程间,用的是命名管道。
    当一个进程创建了管道后(server),另外一个进程(client)可以连接这个管道。这样一个连接称作为一个 instance (实例)。每个实例与一个管道handle 捆绑。多个instance的概念是,多个连接实例 捆绑 在同一个命名通道,由此实现1对多的管道通信。虽然是自己找到的答案,但还是给分。
    这里只有 4、5 楼的答案比较靠近。