VB6 中的命名管道:CallNamedPipe() 失败,错误为 87

发布于 2024-11-09 20:22:26 字数 657 浏览 6 评论 0原文

我在 VB6 中使用 CallNamedPipe() 将消息发送到 C# 命名管道服务器。 在服务器端,管道是通过以下方式创建的:

new NamedPipeServerStream(pipeName, PipeDirection.InOut, numThreads);

在客户端,我使用此调用写入 2 个字节:

  Dim Header(1) As Byte
  Header(0) = 0
  Header(1) = 6
  res = CallNamedPipe(szPipeName, Header(0), 2, bArray(0), numBytes, cbRead, 3000)

服务器看到管道已连接,因为 WaitForConnection() 确实返回,但随后无法读取任何字节。 在客户端:CallNamedPipe 失败并返回错误代码 87(参数无效?)

我的问题是:

  1. 管道创建的是字节模式还是消息模式类型? MSDN 说如果管道是字节模式,CallNamedPipe() 会失败。

  2. 有没有办法在 VB6 中写入字节模式管道。我是否必须更改服务器代码才能创建消息模式管道?

  3. 如何让我的 VB6 代码工作?

I am using CallNamedPipe() in VB6 to send messages to a C# named pipe server.
On the server side the pipe is created by:

new NamedPipeServerStream(pipeName, PipeDirection.InOut, numThreads);

On the client I use this call to write 2 bytes:

  Dim Header(1) As Byte
  Header(0) = 0
  Header(1) = 6
  res = CallNamedPipe(szPipeName, Header(0), 2, bArray(0), numBytes, cbRead, 3000)

The server saw the pipe connected because WaitForConnection() did return, but then could not read any bytes.
On the client side: CallNamedPipe failed and returned error code 87 (invalid parameters?)

My questions are:

  1. Is the pipe created a byte mode or message mode type? MSDN says CallNamedPipe() fails if the pipe is byte mode.

  2. Is there a way to write to a byte mode pipe in VB6. Do I have to change the server code to create a message mode pipe?

  3. How to get my VB6 code working?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤单情人 2024-11-16 20:22:26

根据文档,当您使用该管道时,管道处于字节模式构造函数。我对非.NET 管道调用了解不多,但我看不出有什么理由不将服务器设置为消息模式管道(如果 VB6 需要)。

According to the documentation, the pipe is in byte mode when you use that constructor. I don't know much about the non-.NET pipe calls, but I don't see any reason why not to set the server to a message mode pipe if the VB6 needs it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文