atl写了个com组件,向外传递一个自定义结构体指针,由于没办法在接口中使用自定义结构体,传出一个long型的值,期望在客户端转换使用,但在C#中引用此com组件时,被定义成int型值,请问C#中如何使用这个“指针”

解决方案 »

  1.   

    客户端不能直接访问com端的内存。
    可以考虑把结构体格式化成BSTR,然后传给客户端
      

  2.   

    "没办法在接口中使用自定义结构体"
    传结构很平常:
    typedef
    [
    uuid(...),
    version(1.0),
    helpstring("Information of SomeInfo")
    ]struct SomeInfo
    {
    int iPort;
    wchar_t wszPassword[32];
    }SomeInfo; [
    object,
    uuid(...),
    dual,
    helpstring("IFoo Interface"),
    pointer_default(unique)
    ]
    interface IFoo : IDispatch
    {
    [id(1), helpstring("method SetInfo")] HRESULT SetInfo([in] SomeInfo si);
    }
    ...