I have a COM method that should return an array. The COM object has other methods which I can access and retrieve info from, but I'm having problems when trying to get the info inside that array. The array is full of zeros when I run my code by the .exe file, but it returns the correct values when I'm running inside the Visual Studio IDE (debug or release). It must be a problem of assignment or initialization of the array, or something similar, but I can't see where. The for the safe array is:

Code:
VARIANT *VarResultRRDS;
VarResultRRDS = new VARIANT;
VariantInit(VarResultRRDS);

//call the method
hr = pl->Invoke(dispidReadRawDataStream, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispparamsRRDS, VarResultRRDS, &ExcepInfo, NULL);

SAFEARRAY* pSafeArray = (*VarResultRRDS).parray;
long lBound, uBound;
SafeArrayGetLBound(pSafeArray, 1, &lBound);
SafeArrayGetUBound(pSafeArray, 1, &uBound);
LONG count = uBound - lBound + 1;
short * pVals;
SafeArrayAccessData(pSafeArray, (void**)&pVals);
vector<short> rrds_out(pVals, pVals + count);

// destroy everything
VariantClear(VarResultRRDS);
When I run this inside the Visual Studio debugger it returns the correct value, if I do it by executing the .exe file it returns zeroes. I'm also able to retrieve integers (from the same COM) in the VS and in the .exe file, however it "fails" for the array. What am I doing wrong???