How can I put VARIANT into COleSafeArray? I tried
Variant vara;
COleSafeArray force= vara;
and got "debug assertion failed"
I used a library to convert voltage value to Force value. In Library, there is below function:
VARIANT _Calibration::ConvertToFT(VARIANT* Voltages, LPCTSTR ForceUnits, LPCTSTR TorqueUnits)
{
VARIANT result;
static BYTE parms[] =
VTS_PVARIANT VTS_BSTR VTS_BSTR;
InvokeHelper(0x60030040, DISPATCH_METHOD, VT_VARIANT, (void*)&result, parms,
Voltages, ForceUnits, TorqueUnits);
return result;
}
So in my main program:
COleSafeArray voltagesk;
double voltages[6];
_read-voltage(voltages);
long y;
for (y = 0; y<6; y++) {
// COleSafeArrays use pass-by-reference methods to read or write
voltagesk.PutElement(&y, &(voltages[y]));
}
COleSafeArray forces = GetActiveCalibration().ConvertToFT(voltagesk, L"lb", L"in-lb");
for (y = 0; y<6; y++) {
// COleSafeArrays use pass-by-reference methods to read or write
forces.GetElement(&y, &(voltages[y]));
I tried deleting this line"COleSafeArray forces = GetActiveCalibration().ConvertToFT(voltagesk, L"lb", L"in-lb");
", my program ran well, but cannot convert voltage into force so I think that converting from VARIANT to COleSafeArray, has problem