Comment example for C++ Builder
This example does the following:
| 1. | Loads an image from a TIFF file. | 
| 2. | Updates the current comment array by reading comments from the file. | 
| 3. | Modifies one of the comments. | 
| 4. | Modifies and saves the file. | 
| 5. | Reads the comment that was saved, and displays it in a message box. | 
This example handles only string comments. For more complex comments, refer to Exif Examples.
   AnsiString MyCommentText; //String for CMNT_SZDESC
     AnsiString FilePath; //File to be updated
     long i; //Loop counter and array index
   LEADRasterIO* pRasterIO= NULL;
   LEADRasterProcess* pRasterProc= NULL;
   ILEADRasterVariant* pRasterVarEmpty;
   ILEADRasterVariant* pRasterVar;
   CoCreateInstance(CLSID_LEADRasterIO, NULL, CLSCTX_ALL, IID_ILEADRasterIO, (void**)&pRasterIO);
     CoCreateInstance(CLSID_LEADRasterProcess, NULL, CLSCTX_ALL, IID_ILEADRasterProcess, (void**)&pRasterProc);
   CoCreateInstance( CLSID_LEADRasterVariant, NULL, CLSCTX_ALL, IID_ILEADRasterVariant,(void**)&pRasterVarEmpty);
   CoCreateInstance( CLSID_LEADRasterVariant, NULL, CLSCTX_ALL, IID_ILEADRasterVariant,(void**)&pRasterVar);
   //Specify the file that we will update.
   FilePath = "c:\\temp\\Test.tif";
   //Get all of the current comments from the file.
   //Temporarily disable method errors so that we do not fail when comments are missing.
   pRasterIO->EnableMethodErrors = False;
   for (i = 0; i<= CMNT_LAST; i++)
   {
      pRasterIO->set_Comment ((short)i, pRasterVarEmpty);
      pRasterIO->set_Comment((short)i, pRasterIO->ReadComment(LEADRasterView1->Raster, AnsiToOLESTR(FilePath.c_str()), 1, (short)i));
   }
     //Load and modify the image.
     pRasterIO->EnableMethodErrors = False;
     pRasterIO->Load(LEADRasterView1->Raster, AnsiToOLESTR(FilePath.c_str()), 0, 0, 1);
     pRasterProc->Reverse(LEADRasterView1->Raster);
     //Update the CMNT_SZDESC comment.
     MyCommentText = "\nThis image has been reversed.";
   pRasterVar->set_Type( VALUE_STRING );
   pRasterVar= pRasterIO->get_Comment(CMNT_SZDESC);
   pRasterVar->StringValue= pRasterVar->StringValue & MyCommentText;
     pRasterIO->set_Comment ( CMNT_SZDESC, pRasterVar );
     //Save the file and read the comment that we saved.
     pRasterIO->Save(LEADRasterView1->Raster, AnsiToOLESTR(FilePath.c_str()), FILE_TIF, LEADRasterView1->Raster->BitmapBits, (QFactorConstants)0, SAVE_OVERWRITE);
     pRasterVar= pRasterIO->ReadComment (LEADRasterView1->Raster, AnsiToOLESTR(FilePath.c_str()), 1, CMNT_SZDESC);
     //Display the message
   ShowMessage (pRasterVar->StringValue );
     //Clear the comments from memory
   for (i = 0; i<= CMNT_LAST; i++)
      pRasterIO->set_Comment((short)i, pRasterVarEmpty);
   if ( pRasterProc )
      pRasterProc-> Release( );
   if ( pRasterProc )
      pRasterIO-> Release( );
   if ( pRasterVarEmpty )
      pRasterVarEmpty->Release ( );
   if ( pRasterVar )
      pRasterVar->Release ( );