请看我的代码,因从数据库中取数据,有很多字段,如果把这些字段都一一作为输入参数会很不直观,为方便我打算用struct数组传递,但下面这段代码不支持自动化。
在idl中如下:
struct Element{...};
HRESULT AddElement([in]SAFEARRAY(Element)* Elem); 我打算用VARIANT,里面用SafeArray传递但会导致编程的麻烦。
请问各位遇到这种问题是怎么处理的,有没有好的方法大家一起交流一下。

解决方案 »

  1.   

    在IDL中定义数据类型
    如:
    interface iMyInterface : IUnknow{
    typedef struct tagMystr{
    long nL;
    short sS;
    } Mystr;HRESULT PutIt( [in]const Mystr * pMystr);
    }
      

  2.   

    http://www.codeguru.com/activex/comarray_struct.shtml
    Passing arrays of structures in COM - Reg Anderson (1999/03/05)
      

  3.   

    netsbull(网牛) 的HRESULT PutIt( [in]const Mystr * pMystr);是否支持自动化方式呢?因该组件要在浏览器里调用,所以需支持自动化数据类型。
      

  4.   

    可以返回记录集,我用过ADO访问数据库(COM中)