|
楼主 |
发表于 2006-5-16 20:21
|
显示全部楼层
回复:(happy)回复:(xiaole170)这个错误信息主要...
<P>就是在调用memcpy(outp,b.parray->pvData,1*sizeof(double));这一句时出现的。<BR>以下是在C++ Builder中调用COM组件的代码,在参数传递时老出现这个问题。<BR>double src1[1];// 传入数据数组<BR>double src2[1];<BR>double src3[1];<BR>double outp[1];//传出数据数组<BR>SAFEARRAY InSafeArray1;//用于传入的安全数组<BR>SAFEARRAY InSafeArray2;<BR>SAFEARRAY InSafeArray3;<BR>TVariant a1;//传入COM的变体<BR>TVariant a2;<BR>TVariant a3;<BR>TVariant b;//传出COM的变体<BR>src1[0]=0.05;//传入数据赋值<BR>src2[0]=3;<BR>src3[0]=4;</P>
<P>InSafeArray1.cDims=1;//设置输入安全数组<BR>InSafeArray1.fFeatures=FADF_AUTO;<BR>InSafeArray1.cbElements=sizeof(double);<BR>InSafeArray1.rgsabound[0].lLbound=0;<BR>InSafeArray1.cLocks=1;<BR>InSafeArray1.rgsabound[0].cElements=1;<BR>VariantInit(&a1);<BR>InSafeArray1.pvData=src1;<BR>a1.SetSAFEARRAY(&InSafeArray1);<BR>a1.vt=VT_R8|VT_ARRAY;<BR>InSafeArray2.cDims=1;//设置输入安全数组<BR>InSafeArray2.fFeatures=FADF_AUTO;<BR>InSafeArray2.cbElements=sizeof(double);<BR>InSafeArray2.rgsabound[0].lLbound=0;<BR>InSafeArray2.cLocks=1;<BR>InSafeArray2.rgsabound[0].cElements=1;<BR>VariantInit(&a2);<BR>InSafeArray2.pvData=src2;<BR>a2.SetSAFEARRAY(&InSafeArray2);<BR>a2.vt=VT_R8|VT_ARRAY;<BR>/*InSafeArray3.cDims=1;//设置输入安全数组<BR>InSafeArray3.fFeatures=FADF_AUTO;<BR>InSafeArray3.cbElements=sizeof(double);<BR>InSafeArray3.rgsabound[0].lLbound=0;<BR>InSafeArray3.cLocks=1;<BR>InSafeArray3.rgsabound[0].cElements=1;<BR>VariantInit(&a3);<BR>InSafeArray3.pvData=src3;<BR>a3.SetSAFEARRAY(&InSafeArray3);<BR>a3.vt=VT_R8|VT_ARRAY;*/</P>
<P>Probability_Distributing1->t_check_up_know(1,&b,a1,a2);<BR>memcpy(outp,b.parray->pvData,1*sizeof(double));<BR>Edit1->Text=int(outp[0]);</P> |
|