问题描述
我正在编写一个项目并使用另一方 DLL.
I'm writing a project and working with another party DLL.
他们的 DLL 中的函数想要一个 IStream 对象来保存结果,但我不明白如何创建一个 IStream 对象.
Function from their DLL wants an IStream object to save result, but I can't understand how to create an IStream object.
谁能帮我解决我的问题?
Can anyone help me with my problem?
推荐答案
你不要创建 IStream 对象,因为它显然是一个接口.您应该实现此接口并传递您的对象.或者干脆使用一个已经实现它的对象,如果这样的对象存在的话.
You don't create IStream object, because obviously it's an interface. You should rather implement this interface and pass your object. Or simply use an object that already implements it, if such object exists.
已经给出了类似问题的答案,给出了一个很好的例子,如何在 C# 中使用 IStream 接口.
Already given answer for a similar question gives a nice example how to use IStream interface in C#.
为 COM 做一个包装类互操作 IStream 已经存在?
更正:但是,这仅在您需要在应用程序中使用现有的 IStream 时才有效,而不是当您需要在其他地方创建和传递 IStream 时.对于该任务,请参阅this for refence 如何执行此操作:
Correction: This, however, works only if you need to use already an existing IStream inside your app, not when you need to create and pass an IStream elsewhere. For that task, see this for refence how to do that:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa380034(v=vs.85).aspx
这是来自 Microsoft 的示例(用于 XmlLite,不确定是否适合您)
And here is an example from Microsoft (used for XmlLite, not sure if it works for you)
http://msdn.microsoft.com/en-us/library/windows/desktop/ms752876(v=vs.85).aspx
或者也许这个例子已经由 Marcus 发布:http://hl7connect.blogspot.sk/2010/04/c-implementation-of-istream.html
Or maybe this example, already posted by Marcus: http://hl7connect.blogspot.sk/2010/04/c-implementation-of-istream.html
最后一个链接展示了如何使用任何 Stream 来实现 IStream 接口.
This last link shows how to use any Stream to implement the IStream interface.
这篇关于在 C# 中创建 IStream 对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!