المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Convert BYTE* array (unmanaged) to SAFEARRAY



C++ Programming
10-23-2009, 06:30 AM
SAFEARRAY* arr;

int iRes = RestoreFactory(bstrPath, // this function is for c#com object &arr);

// Copy SAFEARRAY* values to output
int iSize;
if ( arr != NULL )
{
iSize = arr->rgsabound[0].cElements;
BYTE *byteArr = new BYTE[iSize];
for (int i = 0; i < iSize; i++)
{
byteArr[i] = ((BYTE)((( char *)(*arr).pvData)[i]));
}
}

The byteArr seems to be wrong!
Is it the right convertion???

Thanks!