如何定义和编组BSTR *类型
我想知道如何将字符串类型编组为BSTR *类型。 只是为了阐述,C ++结构如下:
struct MyStruct
{
BSTR* string;
int a;
}
我需要在C#端定义一个新的sturct,我尝试了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);
尝试这个:
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
struct MyStruct
{
[MarshalAs(UnmanagedType.BStr)] public String myString;
public int a;
}
链接地址: http://www.djcxy.com/p/66599.html