javascript好像没有struct类型,也不能memcpy,我怎么传给activex里面呢?

解决方案 »

  1.   

    用流(IStream)Command what is yours
    Conquer what is not
      

  2.   

    用流(IStream)怎样用啊???
      

  3.   

    javascript和vbscript这样的脚本语言调用com组件使用的是自动化模式,其所有变量都是variant型的,所以在com(activeX)的输入和输出接口中变量只能使用variant(VARIANT*)型.其中对于com输入参数,可以在输入后在com线程内将variant变换成相应的变量类型,你可以使用VariantChangeType函数进行转换;对于com输出参数,javascript和vbscript都会自动为你进行转换,所以在脚本线程内不必对类型转换过多考虑,只是偶尔会转换的类型不能满足你的需要时,才进行一些强制转换,如在vbscript中使用CInt,在javascript中使用parseFloat等函数.
      

  4.   

    没有IDispatch接口,javascript是没办法支持IStream的。我的做法是自己定义一个自动化对象用来传递数据。
    比如像这样:
    interface IPoint : IDispatch
    {
    [propget, id(1), helpstring("property x")] HRESULT x([out, retval] long *pVal);
    [propput, id(1), helpstring("property x")] HRESULT x([in] long newVal);
    [propget, id(2), helpstring("property y")] HRESULT y([out, retval] long *pVal);
    [propput, id(2), helpstring("property y")] HRESULT y([in] long newVal);
    HRESULT GetPoint([out] POINT* pt);
    HRESULT PutPoint([in] POINT* pt);
    };