Assuming you have the variant containing the data then this function will extract the data and put it into *ppBuf: bool GetBinaryFromVariant( VARIANT& vData, BYTE ** ppBuf, unsigned long * pcBufLen ) { bool bReturn = false; //Binary data is stored in the variant as an array of unsigned char if( vData.vt == ( VT_ARRAY|VT_UI1 ) ) { //Retrieve size of array *pcBufLen = vData.parray->rgsabound[0].cElements; //Allocate a buffer to store the data *ppBuf = new BYTE[*pcBufLen]; if(*ppBuf != NULL) { void* pArrayData; //Obtain safe pointer to the array SafeArrayAccessData(vData.parray,&pArrayData); //Copy the bitmap into our buffer memcpy(*ppBuf, pArrayData, *pcBufLen); //Unlock the variant data SafeArrayUnaccessData(vData.parray); bReturn = true; } } return bReturn; } Then you would use it like this - the code is from the top of my head so I'm not sure it will compile or work correctly :-) BYTE* pBuffer = NULL; UINT nBufSize = 0; if ( GetBinaryFromVariant( vtJPEG, &pBuffer, &nBufSize ) ) { //Safe the buffer to file: CFile file; if ( file.Open( strTheFileName, CFile::modeCreate | CFile::modeTruncate ) ) { file.Write( pBuffer, nBufSize ); } delete [] pBuffer; }
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!