VB6 中的命名管道:CallNamedPipe() 失败,错误为 87
我在 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(参数无效?)
我的问题是:
管道创建的是字节模式还是消息模式类型? MSDN 说如果管道是字节模式,CallNamedPipe() 会失败。
有没有办法在 VB6 中写入字节模式管道。我是否必须更改服务器代码才能创建消息模式管道?
如何让我的 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:
Is the pipe created a byte mode or message mode type? MSDN says CallNamedPipe() fails if the pipe is byte mode.
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?
How to get my VB6 code working?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据文档,当您使用该管道时,管道处于字节模式构造函数。我对非.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.