BOOL CADORecordset::GetChunk(FieldPtr pField, CString& strValue) { CString str; long lngSize, lngOffSet = 0; _variant_t varChunk; lngSize = pField->ActualSize; //Áг¤¶È str.Empty(); while(lngOffSet < lngSize) { try { varChunk = pField->GetChunk(ChunkSize); str += varChunk.bstrVal; lngOffSet += ChunkSize; } catch(_com_error &e) { dump_com_error(e); return FALSE; } } lngOffSet = 0; strValue = str; return TRUE; }
int CDialerChannel::PlayBlob(int nChan, FieldPtr xPlyBlob, BOOL bTermDtmf) { SsmSetDtmfStopPlay( nChan, bTermDtmf ); SsmClearRxDtmfBuf( nChan ); LONG lDataSize = xPlyBlob->ActualSize; if ( lDataSize <= 0 ) return SsmPutUserEvent( E_PROC_PlayEnd, nChan, 0 ); _variant_t TheValue = xPlyBlob->GetChunk(lDataSize); LPTSTR *pBuf = NULL; SafeArrayAccessData(TheValue.parray, (void **)&pBuf); this->SetBuffer( pBuf, lDataSize ); SafeArrayUnaccessData( TheValue.parray ); if ( SsmPlayMem( nChan, 6, (LPBYTE)BufferPtr, BufferSize, 0, BufferSize - 1 ) ) return SsmPutUserEvent( E_PROC_PlayEnd, nChan, 0 ); return 0; }
BOOL CADORecordset::GetChunk(FieldPtr pField, LPVOID lpData) { long lngSize, lngOffSet = 0; _variant_t varChunk; UCHAR chData; HRESULT hr; long lBytesCopied = 0; lngSize = pField->ActualSize; while(lngOffSet < lngSize) { try { varChunk = pField->GetChunk(ChunkSize); //Copy the data only upto the Actual Size of Field. for(long lIndex = 0; lIndex <= (ChunkSize - 1); lIndex++) { hr= SafeArrayGetElement(varChunk.parray, &lIndex, &chData); if(SUCCEEDED(hr)) { //Take BYTE by BYTE and advance Memory Location //hr = SafeArrayPutElement((SAFEARRAY FAR*)lpData, &lBytesCopied ,&chData); ((UCHAR*)lpData)[lBytesCopied] = chData; lBytesCopied++; } else break; } lngOffSet += ChunkSize; } catch(_com_error &e) { dump_com_error(e); return FALSE; } } lngOffSet = 0; return TRUE; }
//读Buffer bool CRsDupRgn::LoadBufferField(CBaseDBEntity *pGoods, const char* szFiledName, _RecordsetPtr &rs) { if(pGoods == NULL) return false; try { if(rs->GetadoEOF()) { ReleaseRs(rs); return false; } long lSize=0; FieldsPtr fldPtr = rs->GetFields(); FieldPtr itemPtr = fldPtr->GetItem(szFiledName); lSize = itemPtr->ActualSize; if(lSize > 0) { _variant_t varBLOB; varBLOB = itemPtr->GetChunk(lSize); BYTE *pBuf=NULL; SafeArrayAccessData(varBLOB.parray,(void**)&pBuf); SafeArrayUnaccessData(varBLOB.parray); // 清空SKILL CEntityProperty* ep = pGoods->GetDataEntityManager().GetEntityProperty(string(szFiledName)); if(ep) ep->SetBufAttr(0, pBuf, lSize); } } catch(_com_error e) { PrintErr(CStringReading::LoadString(IDS_DBS_RSDUPRGN,STR_DBS_DUPRGN_LOADRGNOBJERR), e); return false; } return true; }