// This function will write the contents of the target// data for the passed capture object to a disk filevoid WriteTargetMemory(LPCWSTR lpwszFileName, IltmmCapture *pCapture){HANDLE hFile = NULL;// open file for outputhFile = CreateFile(lpwszFileName, // open file nameGENERIC_WRITE, // open for writingFILE_SHARE_READ, // share for readingNULL, // no securityCREATE_ALWAYS, // re-create the fileFILE_ATTRIBUTE_NORMAL, // normal fileNULL); // no attr. templateif (hFile == INVALID_HANDLE_VALUE)return;long fl = 0;unsigned long lBytesWritten;IltmmMemory *pTarget = NULL;// try to get the target streampCapture->get_TargetStream((IUnknown**)&pTarget);if(!pTarget)return;VARIANT varData;unsigned char *pBuffer = NULL;SAFEARRAY sa;// get the buffer size and initialize a variantpTarget->get_BufferSize(&fl);VariantInit(&varData);// setup the safe arraymemset(&sa, 0, sizeof(sa));sa.cbElements = sizeof(unsigned char);sa.cDims = 1;sa.fFeatures = (FADF_AUTO | FADF_FIXEDSIZE);sa.pvData = new UCHAR[fl];sa.rgsabound[0].cElements = fl;// associate the safe array with our variantV_VT(&varData) = (VT_ARRAY | VT_UI1);V_ARRAY(&varData) = &sa;// copy the target data to the variant safe array and to our bufferpTarget->CopyData(0, fl, &varData);SafeArrayAccessData(V_ARRAY(&varData), (void**)&pBuffer);// write the buffer out to our fileWriteFile(hFile, pBuffer, fl, &lBytesWritten, NULL);// clean up the variantSafeArrayUnaccessData(V_ARRAY(&varData));VariantClear(&varData);// close the output fileCloseHandle(hFile);// release the target objectpTarget->Release();}
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
