如何为 COM 封送流
我正在使用用 Delphi 编写的需要 Stream 的 COM 对象。
VS 生成的接口请求“对象”类型的参数
comReader.LoadFromStream(object stream)
当我使用 FileStream 或 MemoryStream 时,我收到“无效参数”异常。
如何编组流以实现 COM 完善?
I am consuming a COM object written in Delphi that requires a Stream.
The interface generated by VS requests a parameter of type "object"
comReader.LoadFromStream(object stream)
When I use a FileStream or MemoryStream I get an "Invalid argument"-exception.
How do I marshal a stream for COM consummation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您应该为实现 COM
IStream
接口的 .Net Stream 创建包装器请参阅此 文章(有部分实现)
I think you should create wrapper for .Net Stream that implements COM
IStream
interfaceSee this article (There is partly implementation)
编辑我发现了这个有趣的答案: 如何在 idl 中声明 IStream,以便 Visual Studio 将其映射到 swinterop.comtypes?
基本上,您想要做的是实现
System.Runtime.InteropServices.ComTypes.IStream
或使用现有的实现类。如果一切都失败了,您应该能够使用 UnmanagedMemoryStream 封送任意数据。 (MSDN 页面)
Edit I found this interesting answer: How do I declare an IStream in idl so visual studio maps it to s.w.interop.comtypes?
Basically what you want to do is to implement
System.Runtime.InteropServices.ComTypes.IStream
or use an existing implementing class.If all else fails You should be able to marshal arbitrary data using UnmanagedMemoryStream. (MSDN page)