AnnGetSecondaryMetafile example for C++ Builder

void TForm1::ExampleAnnGetSecondaryMetafile ( HANNOBJECT hObject )
{
   L_INT nObjectType;
   unsigned hMetafile1;
   unsigned hMetafile2;
   bool bEncryptorOriginal;

   nObjectType = LEADAnn1->AnnGetType(hObject);
   if(nObjectType != ANNOBJECT_ENCRYPT)
   {
      ShowMessage("This object is not an encryptor object.");
      return;
   }

   LEADAnn1->AnnGetMetafile(hObject, hMetafile1);
   LEADAnn1->AnnGetSecondaryMetafile ( hObject, hMetafile2);

   LEADAnn1->AnnEncryptOptions->Flags = ANNENCRYPT_ALL;
   LEADAnn1->AnnGetEncryptOptions(hObject);

   bEncryptorOriginal = LEADAnn1->AnnEncryptOptions->Encryptor;

   //Set state to Decryptor and set Decryptor metafile
   LEADAnn1->AnnEncryptOptions->Flags = ANNENCRYPT_TYPE;
   LEADAnn1->AnnFlags = 0;
   LEADAnn1->AnnEncryptOptions->Encryptor = TRUE;
   LEADAnn1->AnnSetEncryptOptions (hObject);
   LEADAnn1->AnnSetMetafile( hObject, hMetafile2, ANNMETAFILE_USER, FALSE);

   //Set state to Decryptor and set Decryptor metafile
   LEADAnn1->AnnFlags = 0;
   LEADAnn1->AnnEncryptOptions->Encryptor = TRUE;
   LEADAnn1->AnnSetEncryptOptions (hObject);
   LEADAnn1->AnnSetMetafile(hObject, hMetafile2, ANNMETAFILE_USER, FALSE);

   LEADAnn1->AnnEncryptOptions->Encryptor = bEncryptorOriginal;
   LEADAnn1->AnnFlags = 0;
   LEADAnn1->AnnSetEncryptOptions (hObject);
}