我想知道如何将字符串类型编组为 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)] public struct HttpTextRenderFilterInfo { public enum 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);