Home > Back-end >  Out-of-process component of VARIANT array how to float array?
Out-of-process component of VARIANT array how to float array?

Time:09-29

I use COM wrote a out-of-process component as the server program, the server has a method of PID (parameters, output), the "parameters" is a VARIANT array, in the realization of PID, the "parameters" into ordinary float array first, before using, do not know this how to convert? I find the code as follows, the Internet is in the same process can realize turn float array VARIANT array, and then convert VARIANT array to float array, but not between processes, Daniel taught ~ ~
The client side is float array into a VARIANT array first:
 
Float para [4]={1, 2, 3, 4};

//double VARIANT
The VARIANT varArg1;
SAFEARRAY * psa;
SAFEARRAYBOUND rgsabound [1].
Rgsabound [0]. LLbound=0;
Rgsabound [0]. CElements=4;//this is the length of the array,
Psa=SafeArrayCreate (VT_R4, 1, rgsabound);//VT_I4 specified 4 byte signed int
For (long k=0; K & lt; (long) 4; K++)
{
SafeArrayPutElement (psa, & amp; K, & amp; Para [k]);//this is conversion
}
VarArg1. N=VT_ARRAY | VT_R4;//specify the VARIANT data type integer array
VarArg1. Parray=psa;//assignment

Out-of-process COM component is a VARIANT array to float array:
 
//the VARIANT double
Float * pValue=https://bbs.csdn.net/topics/NULL;
SAFEARRAY * pArray=varArg1. PArray;
SafeArrayAccessData (pArray, (void * *) & amp; PValue);
Long Low (0), High (0);
SafeArrayGetLBound (pArray, 1, & amp; Low);
SafeArrayGetUBound (pArray, 1, & amp; High);
LONG I;
The float u [4];
For (I=Low; I{
U=pValue [I] [I];
}

CodePudding user response:

Process address should be used
  • Related