Convert BYTE* array (unmanaged) to SAFEARRAY
-
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!
-
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!
TalSt wrote:
The byteArr seems to be wrong!
Namely? :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
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!
TalSt wrote:
Convert BYTE* array (unmanaged) to SAFEARRAY Is it the right convertion???
No. The code you have posted is converting from SAFEARRAY to BYTE[]. Exactly the opposite of your post title. Can you clarify what it is you are trying to achieve? Best Wishes, -David Delaune
-
TalSt wrote:
Convert BYTE* array (unmanaged) to SAFEARRAY Is it the right convertion???
No. The code you have posted is converting from SAFEARRAY to BYTE[]. Exactly the opposite of your post title. Can you clarify what it is you are trying to achieve? Best Wishes, -David Delaune
-
Hello, Yes. You are right. The title is wrong. It should be: "converting from SAFEARRAY to BYTE[]". Do you know if the code is correct? Thanks! :)