【发布时间】:2012-08-11 11:45:56
【问题描述】:
我想知道如何将字符串类型编组为 BSTR* 类型。 详细说明一下,C++结构如下:
struct MyStruct
{
BSTR* string;
int a;
}
我需要在 C# 端定义一个新结构,我尝试了 string[] 和 IntPtr[] 但没有成功。
感谢您的帮助!
编辑: c++结构:
struct HTTPTEXTRENDERERFILTERINFO {
enum { UTC, GMT } eTimestamp;
BOOL bEnableCCIngest;
LONG lQueueSizeTreshold;
LONG lSendTimeTreshold;
BYTE btBroadcastUrlCount;
BSTR* pbstrBroadcastUrls;
LONG lInputPinsNum;
};
以及函数的原型:
HRESULT HTTPTextRendererFilter::SetConfig(IN const HTTPTEXTRENDERERFILTERINFO& Config)
c#结构:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] 公共结构 HttpTextRenderFilterInfo { 公共枚举 TimestampType : int { UTC, GMT };
public TimestampType Timestamp; public int EnableCCIngest; public int QueueSizeTreshold; public int SendTimeTreshold; public byte BroadcastUrlCount; [MarshalAs(UnmanagedType.BStr)] public string pbstrBroadcastUrls; public int lInputPinsNum; };
原型:
[PreserveSig]
int SetConfig([In] ref HttpTextRenderFilterInfo config);
【问题讨论】:
标签: c# c++ marshalling com-interop unmarshalling