AnnSaveArray example for C++ 4.0 and later

Note: This topic is for Document/Medical only.

//This sample saves the currently loaded annotations in memory (as a VARIANT)
//The variant is then saved as a readable annotation file
void CVCsampleLoadMemoryDlg::OnButtonAnnsavearray()
{
   COleVariant AnnVariant; 
   long lSize,lUBound,lLBound; 
   HFILE hFile; 
   void HUGEP* pData=NULL; 
   char *pszAnnFile = "d:\\work\\images\\a.ann";
   
   AnnVariant.Clear();
   m_Lead1.AnnSaveArray (&AnnVariant, ANNFMT_ENCODED, FALSE, SAVE_OVERWRITE, 0); 
   
   hFile = _lcreat(pszAnnFile, 0); 
   //hFile = _lopen(pszAnnFile, OF_READWRITE); 
   SafeArrayAccessData(AnnVariant.parray, &pData); 
   SafeArrayGetUBound(AnnVariant.parray, 1, &lUBound); 
   SafeArrayGetLBound(AnnVariant.parray, 1, &lLBound); 
   lSize = lUBound-lLBound + 1; 
   _lwrite(hFile, (LPCSTR)pData, lSize); 
   SafeArrayUnaccessData(AnnVariant.parray); 
   _lclose(hFile); 
}