访问“Mapi32.dll”用 C#

发布于 2024-09-01 01:10:43 字数 1146 浏览 4 评论 0原文

我正在使用 VS 2008 C# Windows 应用程序。

我正在尝试使用这个 DLL 导入。

[DllImport("Mapi32.dll", PreserveSig = true)]
private static extern void
WrapCompressedRTFStream(
[MarshalAs(UnmanagedType.Interface)]
UCOMIStream lpCompressedRTFStream,
uint ulflags,
[MarshalAs(UnmanagedType.Interface)]
out UCOMIStream lpUncompressedRTFStream
);

public const uint MAPI_MODIFY = 0x00000001;
public const uint STORE_UNCOMPRESSED_RTF = 0x00008000;

我有一个 CompressedRFTFormat 格式的压缩字符串。

如何将字符串传递到 WrapCompressedRTFStream 中?我不明白该方法的期望是什么。

我正在尝试在按钮上使用它。

RichText1.text = WrapCompressedRTFStream(_CompressedRichText.ToString(),某事,某事);

我得到的第一个错误是“无法从‘string’转换为‘System.Runtime.InteropServices.UCOMIStream’”

我希望理解这一点的人发布一个有帮助的答案!

好的,所以当我使用 IStream 时,我最终会遇到同样的情况。

[DllImport("Msmapi32.dll", PreserveSig = true)]
private static extern void WrapCompressedRTFStream(
[MarshalAs(UnmanagedType.Interface)]
    IStream lpCompressedRTFStream,
uint ulflags,
[MarshalAs(UnmanagedType.Interface)]
    out IStream lpUncompressedRTFStream
);

这里真正的问题是我不明白如何/如何处理此方法的输入和输出。

I am using VS 2008 C#
Windows Application.

I have this DLL Import I am trying to use.

[DllImport("Mapi32.dll", PreserveSig = true)]
private static extern void
WrapCompressedRTFStream(
[MarshalAs(UnmanagedType.Interface)]
UCOMIStream lpCompressedRTFStream,
uint ulflags,
[MarshalAs(UnmanagedType.Interface)]
out UCOMIStream lpUncompressedRTFStream
);

public const uint MAPI_MODIFY = 0x00000001;
public const uint STORE_UNCOMPRESSED_RTF = 0x00008000;

I have a compressed string that is in CompressedRFTFormat.

How do I pass the string into the WrapCompressedRTFStream? I do not understand what the method is expecting.

I am trying to use it on a button.

RichText1.text = WrapCompressedRTFStream(_CompressedRichText.ToString(),something,somethingelse);

The first error I get is "cannot convert from 'string' to 'System.Runtime.InteropServices.UCOMIStream"

I hope someone who understands this posts an answer that helps!

ok, so I end up in the same situation when I use the IStream.

[DllImport("Msmapi32.dll", PreserveSig = true)]
private static extern void WrapCompressedRTFStream(
[MarshalAs(UnmanagedType.Interface)]
    IStream lpCompressedRTFStream,
uint ulflags,
[MarshalAs(UnmanagedType.Interface)]
    out IStream lpUncompressedRTFStream
);

The real issue here is I do not understand what / how to deal with the input and output of this method.

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

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

发布评论

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

评论(3

苍白女子 2024-09-08 01:10:43

我认为使用遗留的本机代码库并不是一个好主意。我会花更多时间在 .net 中查找类似的代码

尝试使用 com interopp-invoke .net 技术来使用遗留代码。

I suppose it's not a good idea to use legacy native-code libraries & I would investigate some more time to find analogous code in .net

Try out com interop or p-invoke .net technologies to use legacy code.

风情万种。 2024-09-08 01:10:43

如果您找不到执行此操作的本机 .NET 方法,一个好的方法是将您的方法包含在托管 C++ 包装器中。

这将让您创建 C++ 代码来执行您的工作,同时公开托管类来调用该方法。这可能会更复杂,因为它需要您学习托管 C++,但允许您执行任何必要的 C++ 工作,返回包含您的“答案”的 .NET 字符串。

If you can't find a native .NET method for doing this, a good approach would be to contain your approach in a Managed C++ wrapper.

What this will let you do is create C++ code to perform your work, while exposing a managed class to call the method. This may be more complicated since it will require you to learn Managed C++, but allows you to do any C++ work necessary, returning a .NET string containing your "answer".

热血少△年 2024-09-08 01:10:43

UCOMIStream 已弃用,请改用 ComTypes.Istream。然后查看 System.Runtime.InteropServices.ComTypes.IStream 到 System .IO.Stream

UCOMIStream is deprecated, use ComTypes.Istream instead. Then look at System.Runtime.InteropServices.ComTypes.IStream to System.IO.Stream

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