How to define and marshall BSTR* types

i was wondering how to marshall string types to BSTR* types. just to elaborate, the C++ structure is as follows:

struct MyStruct
{
     BSTR* string;
     int a;
}

i need to define a new sturct in C# side, i tried both string[] and IntPtr[] but that didn't come up with a success.

Thanks for your help!

edit: c++ structure:

    struct HTTPTEXTRENDERERFILTERINFO {
        enum { UTC, GMT } eTimestamp;
        BOOL    bEnableCCIngest;
        LONG    lQueueSizeTreshold; 
        LONG    lSendTimeTreshold;  
        BYTE    btBroadcastUrlCount;
        BSTR*   pbstrBroadcastUrls;                                
        LONG    lInputPinsNum;      
    };

and the function's prototype:

HRESULT HTTPTextRendererFilter::SetConfig(IN const HTTPTEXTRENDERERFILTERINFO& Config)

c# structure:

[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;     
};

prototype:

    [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/66600.html

上一篇: 用int *成员将C ++结构编组为C#

下一篇: 如何定义和编组BSTR *类型